diff --git a/CefSharp.MinimalExample.Wpf/App.xaml b/CefSharp.MinimalExample.Wpf/App.xaml index 78e9486..b53d4c4 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml +++ b/CefSharp.MinimalExample.Wpf/App.xaml @@ -1,9 +1,10 @@  - + + diff --git a/CefSharp.MinimalExample.Wpf/Behaviours/HoverLinkBehaviour.cs b/CefSharp.MinimalExample.Wpf/Behaviours/HoverLinkBehaviour.cs new file mode 100644 index 0000000..779c6b1 --- /dev/null +++ b/CefSharp.MinimalExample.Wpf/Behaviours/HoverLinkBehaviour.cs @@ -0,0 +1,34 @@ +using CefSharp.Wpf; +using System.Windows; +using System.Windows.Interactivity; + +namespace CefSharp.MinimalExample.Wpf.Behaviours +{ + public class HoverLinkBehaviour : Behavior + { + // Using a DependencyProperty as the backing store for HoverLink. This enables animation, styling, binding, etc... + public static readonly DependencyProperty HoverLinkProperty = DependencyProperty.Register("HoverLink", typeof(string), typeof(HoverLinkBehaviour), new PropertyMetadata(string.Empty)); + + public string HoverLink + { + get { return (string)GetValue(HoverLinkProperty); } + set { SetValue(HoverLinkProperty, value); } + } + + protected override void OnAttached() + { + AssociatedObject.StatusMessage += OnStatusMessageChanged; + } + + protected override void OnDetaching() + { + AssociatedObject.StatusMessage -= OnStatusMessageChanged; + } + + private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e) + { + var dp = sender as ChromiumWebBrowser; + dp.Dispatcher.Invoke(() => HoverLink = e.Value); + } + } +} diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index e0961cf..1070224 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -67,8 +67,16 @@ app.manifest + + ..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll + True + + + ..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll + True + @@ -94,7 +102,9 @@ App.xaml Code - + + + MainWindow.xaml Code diff --git a/CefSharp.MinimalExample.Wpf/Converter/EnvironmentConverter.cs b/CefSharp.MinimalExample.Wpf/Converter/EnvironmentConverter.cs new file mode 100644 index 0000000..3603b70 --- /dev/null +++ b/CefSharp.MinimalExample.Wpf/Converter/EnvironmentConverter.cs @@ -0,0 +1,18 @@ +using System; +using System.Globalization; + +namespace CefSharp.MinimalExample.Wpf.Converter +{ + class EnvironmentConverter : System.Windows.Data.IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return Environment.Is64BitProcess ? "x64" : "x86"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return System.Windows.Data.Binding.DoNothing; + } + } +} diff --git a/CefSharp.MinimalExample.Wpf/Binding/TitleConverter.cs b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs similarity index 91% rename from CefSharp.MinimalExample.Wpf/Binding/TitleConverter.cs rename to CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs index 145bce5..567e558 100644 --- a/CefSharp.MinimalExample.Wpf/Binding/TitleConverter.cs +++ b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Windows.Data; -namespace CefSharp.MinimalExample.Wpf.Binding +namespace CefSharp.MinimalExample.Wpf.Converter { public class TitleConverter : IValueConverter { diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml b/CefSharp.MinimalExample.Wpf/MainWindow.xaml index 70ad9e3..92127fb 100644 --- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml +++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml @@ -2,25 +2,81 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" + xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core" + xmlns:behaviours="clr-namespace:CefSharp.MinimalExample.Wpf.Behaviours" + xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}" WindowState="Maximized"> + + + + - - - - - - + + + + + + + + + + + + +