From 7d2e20e9e1f24a9caf7eed22d014d30c72e8e87b Mon Sep 17 00:00:00 2001 From: Ben Wallis Date: Sat, 19 Dec 2015 10:47:55 +0000 Subject: [PATCH] Partially fixed Issue #22 - the EditableListBoxControl now accepts enter to add an item and retains focus in the text box after doing so. --- Filtration/UserControls/EditableListBoxControl.xaml | 2 +- Filtration/UserControls/EditableListBoxControl.xaml.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Filtration/UserControls/EditableListBoxControl.xaml b/Filtration/UserControls/EditableListBoxControl.xaml index 67814e0..67ad475 100644 --- a/Filtration/UserControls/EditableListBoxControl.xaml +++ b/Filtration/UserControls/EditableListBoxControl.xaml @@ -41,7 +41,7 @@ - + diff --git a/Filtration/UserControls/EditableListBoxControl.xaml.cs b/Filtration/UserControls/EditableListBoxControl.xaml.cs index 1ea4b10..b83a939 100644 --- a/Filtration/UserControls/EditableListBoxControl.xaml.cs +++ b/Filtration/UserControls/EditableListBoxControl.xaml.cs @@ -2,6 +2,8 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; using Filtration.Annotations; using GalaSoft.MvvmLight.CommandWpf; @@ -106,5 +108,13 @@ namespace Filtration.UserControls var handler = PropertyChanged; handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + + private void AutoCompleteBox_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + AddItemCommand.Execute(null); + } + } } }