diff --git a/CefSharp.MinimalExample.Wpf/App.xaml b/CefSharp.MinimalExample.Wpf/App.xaml index b53d4c4..2632003 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml +++ b/CefSharp.MinimalExample.Wpf/App.xaml @@ -6,5 +6,6 @@ + diff --git a/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs b/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs new file mode 100644 index 0000000..1dcafd7 --- /dev/null +++ b/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs @@ -0,0 +1,28 @@ +using System.Windows.Interactivity; +using System.Windows.Controls; +using System.Windows.Input; + +namespace CefSharp.MinimalExample.Wpf.Behaviours +{ + public class TextBoxBindingUpdateOnEnterBehaviour : Behavior + { + protected override void OnAttached() + { + AssociatedObject.KeyDown += OnTextBoxKeyDown; + } + + protected override void OnDetaching() + { + AssociatedObject.KeyDown -= OnTextBoxKeyDown; + } + + private void OnTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + var txtBox = sender as TextBox; + txtBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); + } + } + } +} diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index 2904c57..c1348cd 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -103,6 +103,7 @@ Code + diff --git a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs index 567e558..d78aadc 100644 --- a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs +++ b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs @@ -6,15 +6,14 @@ namespace CefSharp.MinimalExample.Wpf.Converter { public class TitleConverter : IValueConverter { - object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return "CefSharp.MinimalExample.Wpf - " + (value ?? "No Title Specified"); } - object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return System.Windows.Data.Binding.DoNothing; + return Binding.DoNothing; } } } diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml b/CefSharp.MinimalExample.Wpf/MainWindow.xaml index e5ba808..3b1c2c3 100644 --- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml +++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml @@ -31,25 +31,35 @@