Partially fixed Issue #22 - the EditableListBoxControl now accepts enter to add an item and retains focus in the text box after doing so.
This commit is contained in:
parent
bb45832d7a
commit
7d2e20e9e1
|
@ -41,7 +41,7 @@
|
||||||
<KeyBinding Key="Delete" Command="{Binding Path=DeleteItemCommand}" CommandParameter="{Binding ElementName=ControlListBox, Path=SelectedValue}" />
|
<KeyBinding Key="Delete" Command="{Binding Path=DeleteItemCommand}" CommandParameter="{Binding ElementName=ControlListBox, Path=SelectedValue}" />
|
||||||
</ListBox.InputBindings>
|
</ListBox.InputBindings>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<toolkit:AutoCompleteBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding AutoCompleteItemsSource}" FilterMode="Contains" Text="{Binding AddItemText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
|
<toolkit:AutoCompleteBox x:Name="AutoCompleteBox" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding AutoCompleteItemsSource}" FilterMode="Contains" Text="{Binding AddItemText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" PreviewKeyDown="AutoCompleteBox_OnPreviewKeyDown" />
|
||||||
<Button Grid.Row="1" Grid.Column="1" Command="{Binding AddItemCommand}" IsDefault="True">Add</Button>
|
<Button Grid.Row="1" Grid.Column="1" Command="{Binding AddItemCommand}" IsDefault="True">Add</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
using Filtration.Annotations;
|
using Filtration.Annotations;
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
|
|
||||||
|
@ -106,5 +108,13 @@ namespace Filtration.UserControls
|
||||||
var handler = PropertyChanged;
|
var handler = PropertyChanged;
|
||||||
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AutoCompleteBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
AddItemCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue