I have a RadAutoCompleteBox in RadGridView CellEditTemplate
public class AutoCompleteCell : RadAutoCompleteBox{ public AutoCompleteCell() { SelectionMode = AutoCompleteSelectionMode.Single; Unloaded += unloaded; Loaded += loaded; } private void loaded(object sender, RoutedEventArgs e) { //all has value string searchText = SearchText; object selectedItem = SelectedItem; } private void unloaded(object sender, RoutedEventArgs e) { string searchText = SearchText; //has value object selectedItem = SelectedItem; //no value }}
SearchText is in dropdown ItemsSource, when I click the cell and enter edit mode, Loaded event fired and both SearchText and SelectedItem has value, but when I just press Esc to exit edit mode and in Unloaded event, SearchText still has value but SelectedItem is null.
Why this happened and how to fix it? Thanks.
<controls:AutoCompleteCell SelectedItem="{Binding Value, Mode=TwoWay}" ItemsSource="{Binding Source, Mode=OneWay}" SearchText="{Binding Header, Mode=OneWay}" />
"Header" is returned from "Value".