private async void AddButton_Click(object sender, RoutedEventArgs e) { if (sender is Button button) { var editWindow = EditPanel; var content = new EditTeamControl() { Header = "Add new Team", SubmitText = "Add" }; if (content.DataContext is TeamViewModel editVM) { editVM.Model = new TeamModel() { Name = "New Team", TeamColor = "#666666" }; editWindow.ModalContent = content; if (editWindow.ShowDialog() == true) { await ViewModel?.AddTeam(editVM.Model); } } } }
private async void EditButton_Click(object sender, RoutedEventArgs e) { if (sender is Button button && button.Tag is TeamViewModel teamVM) { var editWindow = EditPanel; var content = new EditTeamControl(); editWindow.Title = "Edit Team Data"; if (content.DataContext is TeamViewModel editVM) { editVM.Model.CopyFrom(teamVM.Model); editWindow.ModalContent = content; if (editWindow.ShowDialog() == true) { teamVM.Model.CopyFrom(editVM.Model); await teamVM.SaveChanges(); } } } }