please have look on my code, this become an infinite loop while calling lostfocus event of combo box i need some data from database and user can select data only form list with typing options.
mainwindow.xaml
<Grid>
<TextBox x:Name="txt1" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" Margin="112,10,0,0"/>
<ComboBox x:Name="cmb" GotFocus="cmbgotfocus" LostKeyboardFocus="cmblost" KeyDown="cmbkeydown" IsEditable="True" HorizontalAlignment="Left" VerticalAlignment="Top" Width="238" Margin="112,50,0,0" />
</Grid>
Class
private void cmbkeydown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Escape)
{
cmb.IsDropDownOpen = false;
}
else
{
cmb.IsDropDownOpen = true;
}
}
private void cmblost(object sender, RoutedEventArgs e)
{
if (cmb.SelectedIndex < 0 && cmb.Text!="" )
{
MessageBox.Show("Please select a valid data from list only", "Warning");
cmb.Focus();
}
}