/// <summary> /// Launches the UI to edit an item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditItemButtonClick(object sender, RoutedEventArgs e) { Control control = sender as Control; // The item to edit is bound to the "Tag" property ModifyItemChildWindow window = new ModifyItemChildWindow( ((Item)control.Tag)); window.NewItem = false; window.Closed += new EventHandler(ModifyItemWindowClosed); window.Show(); }
/// <summary> /// Handles launching a UI for creating a new window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewItemButtonClick(object sender, RoutedEventArgs e) { Control control = sender as Control; // The parent list is bound to the "Tag" property ModifyItemChildWindow window = new ModifyItemChildWindow( ((ModelList)control.Tag)); window.NewItem = true; window.Closed += new EventHandler(ModifyItemWindowClosed); window.Show(); }
/// <summary> /// Event handler for the modify item window closed event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ModifyItemWindowClosed(object sender, EventArgs e) { ModifyItemChildWindow window = (ModifyItemChildWindow)sender; // Check if the user clicked OK if (window.DialogResult == true) { ModelItem item = window.Item; if (window.NewItem) { // Add the item ContextModel.Instance.AddItem(item); } // Save the changes ContextModel.Instance.SaveChanges(); } else { // If the user clicked cancel, revert ContextModel.Instance.CancelChanges(); } }
/// <summary> /// Launches the UI to edit an item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditItemButtonClick(object sender, RoutedEventArgs e) { Control control = sender as Control; // The item to edit is bound to the "Tag" property ModifyItemChildWindow window = new ModifyItemChildWindow( ((Item)control.Tag)); window.NewItem = false; window.Closed += new EventHandler(ModifyItemWindowClosed); window.Show(); }
/// <summary> /// Handles launching a UI for creating a new window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewItemButtonClick(object sender, RoutedEventArgs e) { Control control = sender as Control; // The parent list is bound to the "Tag" property ModifyItemChildWindow window = new ModifyItemChildWindow( ((ModelList)control.Tag)); window.NewItem = true; window.Closed += new EventHandler(ModifyItemWindowClosed); window.Show(); }