private void AddElement_Click(object sender, RoutedEventArgs e) { var planetWindow = new PlanetWindow(new Planet()); if (planetWindow.ShowDialog() == true) { PlanetList.Items.Add(planetWindow.planet); } }
private void PlanetList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var planet = PlanetList.SelectedItem as Planet; if (planet == null) { return; } var planetWindow = new PlanetWindow(planet); if (planetWindow.ShowDialog() == true) { var si = PlanetList.SelectedIndex; PlanetList.Items.RemoveAt(si); PlanetList.Items.Insert(si, planetWindow.planet); } if (PlanetList.Items.Count != 0) { DeleteElement.IsEnabled = true; } }
private void PlanetList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var planet = PlanetList.SelectedItem as Planet; if (planet == null) { return; } var planetWindow = new PlanetWindow(planet.Clone()); var res = planetWindow.ShowDialog(); if (res == true) { var si = PlanetList.SelectedIndex; PlanetList.Items.RemoveAt(si); PlanetList.Items.Insert(si, planetWindow.planet); } if (PlanetList.Items.Count != 0) { DeleteElement.IsEnabled = true; } }