private void Create_Click_1(object sender, RoutedEventArgs e) { Channel newChannel = new Channel(); ChannelWPF channelModel = new ChannelWPF(newChannel); if (channelModel.ShowDialog() == true) { newChannel.Count = ListBox.Items.Count + 1; ListBox.Items.Add(newChannel.ToShortStr()); channels.Add(newChannel); } else { MessageBox.Show("Changes are not saved"); } }
private void Change_Click(object sender, RoutedEventArgs e) { int selectedIndex = ListBox.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= channels.Count) { MessageBox.Show("Choose"); return; } ChannelWPF channelModal = new ChannelWPF(channels[ListBox.SelectedIndex]); bool? result = channelModal.ShowDialog(); if (result == true) { ListBox.Items[selectedIndex] = channels[ListBox.SelectedIndex].ToShortStr(); } else { MessageBox.Show("Changes are not saved"); } }