private void txtBox_LostFocus(object sender, RoutedEventArgs e) { if (!pop.IsKeyboardFocusWithin) { if (string.IsNullOrEmpty(this.txtBox.Text)) SelectedItem = null; Close(CloseReason.LostFocus); } }