private void GroupRenameClick(object sender, RoutedEventArgs e) { if (!((((sender as MenuItem)?.Parent as ContextMenu)?.PlacementTarget as FrameworkElement)?.DataContext is MallowGroup group)) { return; } string result = RenameWindow.Rename(group.Name); if (!string.IsNullOrEmpty(result)) { group.Name = result; } }
public static string Rename(string origin) { RenameWindow window = new RenameWindow { RenameTextBox = { Text = origin } }; window.RenameTextBox.Focus(); window.ShowDialog(); return(window.RenameTextBox.Text); }