MainWindow.xaml - simplify static bindings

HoverLinkBehaviour - Always use BeginInvoke unless there's an explicit reason for using a sync action
EnvironmentConverter - Minor inconsistencies
This commit is contained in:
amaitland 2017-04-10 10:34:08 +10:00
parent 63d6b44f35
commit 866e3de796
3 changed files with 8 additions and 9 deletions

View File

@ -1,12 +1,13 @@
using CefSharp.Wpf;
using System.Windows;
using System.Windows.Interactivity;
using System;
namespace CefSharp.MinimalExample.Wpf.Behaviours
{
public class HoverLinkBehaviour : Behavior<ChromiumWebBrowser>
{
// Using a DependencyProperty as the backing store for HoverLink. This enables animation, styling, binding, etc...
// 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
@ -27,8 +28,8 @@ namespace CefSharp.MinimalExample.Wpf.Behaviours
private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e)
{
var dp = sender as ChromiumWebBrowser;
dp.Dispatcher.Invoke(() => HoverLink = e.Value);
var chromiumWebBrowser = sender as ChromiumWebBrowser;
chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() => HoverLink = e.Value));
}
}
}

View File

@ -1,9 +1,10 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace CefSharp.MinimalExample.Wpf.Converter
{
class EnvironmentConverter : System.Windows.Data.IValueConverter
public class EnvironmentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@ -12,7 +13,7 @@ namespace CefSharp.MinimalExample.Wpf.Converter
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return System.Windows.Data.Binding.DoNothing;
return Binding.DoNothing;
}
}
}

View File

@ -7,9 +7,6 @@
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}"
WindowState="Maximized">
<Window.Resources>
<cef:Cef x:Key="Cef" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -74,7 +71,7 @@
<Separator Grid.Column="3" />
<StatusBarItem Grid.Column="4">
<TextBlock HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="3" VerticalAlignment="Center">
Chromium: <Run Text="{Binding ChromiumVersion, Source={StaticResource Cef}, Mode=OneTime}" />, CEF: <Run Text="{Binding CefVersion, Source={StaticResource Cef}, Mode=OneTime}" />, CefSharp: <Run Text="{Binding CefSharpVersion, Source={StaticResource Cef}, Mode=OneTime}"/>, Environment: <Run Text="{Binding Converter={StaticResource EnvironmentConverter}, Mode=OneTime}"/>
Chromium: <Run Text="{Binding Source={x:Static cef:Cef.ChromiumVersion}, Mode=OneTime}" />, CEF: <Run Text="{Binding Source={x:Static cef:Cef.CefVersion}, Mode=OneTime}" />, CefSharp: <Run Text="{Binding Source={x:Static cef:Cef.CefSharpVersion}, Mode=OneTime}"/>, Environment: <Run Text="{Binding Converter={StaticResource EnvironmentConverter}, Mode=OneTime}"/>
</TextBlock>
</StatusBarItem>
</StatusBar>