private void ModifyToggleButtonClick(object sender, RoutedEventArgs e) { ToggleButton currentModifyToggleButton = (ToggleButton)sender; if (currentModifyToggleButton != lastModifyToggleButton && lastModifyToggleButton != null) { lastModifyToggleButton.IsChecked = false; } lastModifyToggleButton = (bool)currentModifyToggleButton.IsChecked ? currentModifyToggleButton : null; if (lastModifyToggleButton != null) { shelfToModify = (Shelf)ShelfsDataGrid.SelectedItem; AddButtonImage.Source = new BitmapImage(new Uri(@"Assets/Icons/modify.png", UriKind.Relative)); AddButtonTextBlock.Text = "Modyfikuj"; AddShelfTextBox.Text = shelfToModify.ShelfName; } else { shelfToModify = null; AddButtonImage.Source = new BitmapImage(new Uri(@"Assets/Icons/add.png", UriKind.Relative)); AddButtonTextBlock.Text = "Dodaj"; AddShelfTextBox.Clear(); } }
private void AddButtonClick(object sender, RoutedEventArgs e) { AddButton.IsEnabled = false; AddShelfTextBox.IsEnabled = false; if (lastModifyToggleButton != null) { ModifyAction(); } else { AddAction(); } AddShelfTextBox.Clear(); ShelfsDataGrid.DataContext = dB.GetShelfs(); AddButton.IsEnabled = true; AddShelfTextBox.IsEnabled = true; }