Added minimal example of how CefSharp can be used. Only WPF so far.
This commit is contained in:
30
CefSharp.MinimalExample.Wpf/Views/Main/MainView.xaml
Normal file
30
CefSharp.MinimalExample.Wpf/Views/Main/MainView.xaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<UserControl x:Class="CefSharp.MinimalExample.Wpf.Views.Main.MainView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="640"
|
||||
d:DesignHeight="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<cefSharp:WebView Grid.Row="0"
|
||||
Address="http://www.google.com"
|
||||
WebBrowser="{Binding WebBrowser, Mode=OneWayToSource}"
|
||||
Title="{Binding Title, Mode=TwoWay}" />
|
||||
<StatusBar Grid.Row="1">
|
||||
<ProgressBar HorizontalAlignment="Right"
|
||||
IsIndeterminate="{Binding WebBrowser.IsLoading}"
|
||||
Width="100"
|
||||
Height="16"
|
||||
Margin="3" />
|
||||
<Separator />
|
||||
<!-- TODO: Could show hover link URL here -->
|
||||
<TextBlock />
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</UserControl>
|
13
CefSharp.MinimalExample.Wpf/Views/Main/MainView.xaml.cs
Normal file
13
CefSharp.MinimalExample.Wpf/Views/Main/MainView.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CefSharp.MinimalExample.Wpf.Views.Main
|
||||
{
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MainViewModel();
|
||||
}
|
||||
}
|
||||
}
|
39
CefSharp.MinimalExample.Wpf/Views/Main/MainViewModel.cs
Normal file
39
CefSharp.MinimalExample.Wpf/Views/Main/MainViewModel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using CefSharp.MinimalExample.Wpf.Mvvm;
|
||||
using CefSharp.Wpf;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace CefSharp.MinimalExample.Wpf.Views.Main
|
||||
{
|
||||
public class MainViewModel
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private IWpfWebBrowser webBrowser;
|
||||
public IWpfWebBrowser WebBrowser
|
||||
{
|
||||
get { return webBrowser; }
|
||||
set { PropertyChanged.ChangeAndNotify(ref webBrowser, value, () => WebBrowser); }
|
||||
}
|
||||
|
||||
private string title;
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set { PropertyChanged.ChangeAndNotify(ref title, value, () => Title); }
|
||||
}
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
PropertyChanged += OnPropertyChanged;
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Title")
|
||||
{
|
||||
Application.Current.MainWindow.Title = "CefSharp.MinimalExample.Wpf - " + Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user