private void New_Click(object sender, RoutedEventArgs e) { NewGroupWindowInstance = NewGroupWindowInstance ?? new NewGroupWindow(); NewGroupWindowInstance.Owner = this; NewGroupWindowInstance.Add.Click -= NewGroupWindowInstance.Done_Click; NewGroupWindowInstance.Add.Click += NewGroupWindowInstance.Add_Click; NewGroupWindowInstance.Show(); }
private void ContextMenuEditButton_Click(object sender, RoutedEventArgs e) { if (GroupsList.SelectedItem != null & GroupsList.SelectedItems.Count == 1) { NewGroupWindowInstance.Add.Click -= NewGroupWindowInstance.Add_Click; NewGroupWindowInstance.Add.Click += NewGroupWindowInstance.Done_Click; NewGroupWindowInstance.Add.Content = "DONE"; var currentElement = GroupsList.SelectedItem as SchoolGroup; NewGroupWindowInstance.NameTextBox.Text = currentElement.Name; NewGroupWindowInstance.StudentsQuantityTextBox.Text = currentElement.StudentQuantity.ToString(); NewGroupWindowInstance.Show(); } else { MessageBox.Show("Choose one group"); } }