private void btnEdit_Click(object sender, RoutedEventArgs e) { ScriptItem item = this.lbxCmds.SelectedItem as ScriptItem; if (item != null) { ScriptCmdEdit win = new ScriptCmdEdit(this, item); win.ShowDialog(); if (win.IsChanged) { this.lbxCmds.ItemsSource = null; this.copy.Items.Remove(item); this.copy.Items.Add(item); this.lbxCmds.ItemsSource = this.copy.Items; } } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { ScriptItem item = new ScriptItem() { Display = "Display Name", Command = "Command text", }; ScriptCmdEdit win = new ScriptCmdEdit(this, item); win.ShowDialog(); if (win.IsChanged) { this.lbxCmds.ItemsSource = null; this.copy.Items.Add(item); this.lbxCmds.ItemsSource = this.copy.Items; } }