private void AddPressed(object sender, RoutedEventArgs e) { if (weaponCollection.Any()) { EditWindow editWindow = new EditWindow(); if (editWindow.ShowDialog() == true) { if (editWindow.myWeapon != null) { weaponCollection.Add(editWindow.myWeapon); } if (lbWeapons.ItemsSource == null) { lbWeapons.ItemsSource = weaponCollection; } lbWeapons.Items.Refresh(); } } }
private void EditPressed(object sender, RoutedEventArgs e) { if (lbWeapons.SelectedIndex == -1) { return; } if (weaponCollection.Any()) { EditWindow editWindow = new EditWindow(); editWindow.myWeapon = lbWeapons.SelectedItem as Weapon; if (editWindow.ShowDialog() == true) { if (editWindow.myWeapon != null) { weaponCollection[lbWeapons.SelectedIndex] = editWindow.myWeapon; } lbWeapons.Items.Refresh(); } } }