/// <summary> /// Click event to add button /// </summary> /// <param name="sender">object</param> /// <param name="e">event information</param> private void Add_Click(object sender, RoutedEventArgs e) { WindowAdd win = new WindowAdd(); win.Owner = this; win.ShowDialog(); //Checking the added object if (win.studObj != null || win.studObj.FirstName != null || win.studObj.Last != null || win.studObj.Age != default(int)) { ((ViewModelM)DataContext).Add(win.studObj); } }
/// <summary> /// Click event edit button /// </summary> /// <param name="sender">objwct</param> /// <param name="e">event information</param> private void Edit_Click(object sender, RoutedEventArgs e) { Student stud = ((ViewModelM)DataContext).SelectedStudent; //Check if the item in the list is selected for editing if (stud == null) { MessageBox.Show("Выберите элемент для редактирования"); return; } WindowAdd win = new WindowAdd(stud); win.Owner = this; win.ShowDialog(); ((ViewModelM)DataContext).Edit(win.studObj); }