WPF-AutoComplete-TextBox
WPF-AutoComplete-TextBox copied to clipboard
SelectionChanged Event?
Is there any way to react in code to when a user has actually selected an item? So an event such as SelectionChanged or SelectedItemChanged?
It's pretty easy to add one. Add it as a RoutedEvent and then send it out at the end of SetSelectedItem. I have this in my local repository but have been having trouble getting it into github. Here's a few snippets.
// part 1 public static readonly RoutedEvent ValueSelectedEvent = EventManager.RegisterRoutedEvent("ValueSelected", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AutoCompleteTextBox));
// part 2 public event RoutedEventHandler ValueSelected { add { AddHandler(ValueSelectedEvent, value); } remove { RemoveHandler(ValueSelectedEvent, value); } }
// part 3 private void SetSelectedItem(object item) { _isUpdatingText = true; SelectedItem = item; _isUpdatingText = false; RaiseEvent(new RoutedEventArgs(ValueSelectedEvent)); }
See last releases