/// <summary> /// Handles the double click. /// </summary> /// <param name="lv">The lv.</param> /// <param name="dictionary">The dictionary.</param> private void HandleDoubleClick(Selector lv, IDictionary<string, string> dictionary) { if (lv.SelectedItem == null) { return; } var item = (KeyValuePair<string, string>)lv.SelectedItem; var modal = new EditItem(item.Key, item.Value) { Owner = this }; if ((bool)(!modal.ShowDialog())) { return; } this.SetValueFromModal(modal, dictionary); if (item.Key != modal.Key && dictionary.ContainsKey(item.Key)) { dictionary.Remove(item.Key); } lv.ItemsSource = null; lv.ItemsSource = dictionary; }
/// <summary> /// Handles the add. /// </summary> /// <param name="lv">The lv.</param> /// <param name="dictionary">The dictionary.</param> private void HandleAdd(ItemsControl lv, IDictionary<string, string> dictionary) { var modal = new EditItem { Owner = this }; if ((bool)(!modal.ShowDialog())) { return; } this.SetValueFromModal(modal, dictionary); lv.ItemsSource = null; lv.ItemsSource = dictionary; }