public static void OnAddNewQuery(object sender, ExecutedRoutedEventArgs e) { TagsDataGrid control = sender as TagsDataGrid; if (control == null) { return; } if (e.OriginalSource is DataGridCell) { try { ScadaDeviceUpdateQuery query = (ScadaDeviceUpdateQuery)((DataGridCell)e.OriginalSource).DataContext; CustomWindow wnd = new CustomWindow(); query.Name += "_Copy"; TagSettingsControl cl = new TagSettingsControl(query, true); wnd.Content = cl; wnd.Title = "Add New Tag"; wnd.MinHeight = 260; wnd.MaxHeight = 380; wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner; wnd.Owner = Window.GetWindow(control); wnd.ShowDialog(); } catch (InvalidCastException ex) { control.AddTagMethod(); } } }
private void AddTagMethod() { CustomWindow wnd = new CustomWindow(); //CustomWindow wnd = new CustomWindow(); TagSettingsControl cl = new TagSettingsControl(); wnd.Content = cl; wnd.Title = "Add New Tag"; wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner; wnd.Owner = Window.GetWindow(this); wnd.MinHeight = 260; wnd.MaxHeight = 380; wnd.MinWidth = 360; wnd.MaxWidth = 680; wnd.ShowDialog(); }