private void List_Selection(object sender, SelectionChangedEventArgs e) { var Patient = PatientList.SelectedItem as Patient; if (Patient != null) { var window = new SelectedPatient(Patient) { Owner = (Window)PresentationSource.FromVisual(this).RootVisual }; window.Closed += Window_Closed; window.ShowDialog(); PatientList.UnselectAll(); } if (!string.IsNullOrEmpty(SearchTextBox.Text)) { SearchTextBox.Text = string.Empty; } }