WPF-AutoComplete-TextBox icon indicating copy to clipboard operation
WPF-AutoComplete-TextBox copied to clipboard

SelectionChanged Event?

Open afzal646 opened this issue 6 years ago • 1 comments

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?

afzal646 avatar Jan 09 '19 05:01 afzal646

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)); }

clawfrank avatar Jan 18 '19 21:01 clawfrank

See last releases

quicoli avatar Nov 06 '22 12:11 quicoli