private void OkButton_Click(object sender, RoutedEventArgs e) { if (NameTextBox.Text.Trim() == string.Empty) { return; } if (NameTextBox.DataContext == null) { _cc.AddFactory(NameTextBox.Text.Trim()); } _cc.SaveFactories(); NameTextBox.DataContext = null; NameTextBox.Text = string.Empty; HideEditGrid(); }