private void CommitChangesifNeeded(TextBox fe) { ListBoxItem lbi = fe.FindAncestor<ListBoxItem>(); object original = lbi.DataContext; string text = fe.Text; if (string.IsNullOrWhiteSpace(text)) { ItemsSource.Remove(original); return; } object candidat = SF.CreateFromName(text); if (candidat == original) return; LB.SelectedIndex = -1; int Index = ItemsSource.IndexOf(original); if (Index == -1) return; ItemsSource[Index] = candidat; }