I have checked WPF ComboBox with IsEditable as true.
While focus ComboBox, LostFocus event called first time, then GotFocus have called.
How to resolve this?
Code :
XAML:
<Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><StackPanel><ComboBox Height="40" Width="200" Margin="10" GotFocus="ComboBox_GotFocus" LostFocus="ComboBox_LostFocus" IsEditable="True"/><TextBox Text="TextBox" Height="30" Margin="10" Width="200" /></StackPanel><StackPanel Grid.Column="1"><Button Content="Clear" Width="100" Height="50" Margin="10" Click="Button_Click"/><ListView x:Name="listview" Margin="10" Height="300"></ListView></StackPanel></Grid>
C#:
private void ComboBox_GotFocus(object sender, RoutedEventArgs e) { listview.Items.Add("GotFocus"); } private void ComboBox_LostFocus(object sender, RoutedEventArgs e) { listview.Items.Add("LostFocus"); } private void Button_Click(object sender, RoutedEventArgs e) { listview.Items.Clear(); }
Thanks, Muneesh.