This class displays a window which allows the user to modify a new or existing list item
Inheritance: System.Windows.Controls.ChildWindow
Example #1
0
        /// <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();
        }
Example #2
0
        /// <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();
        }
Example #3
0
        /// <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();
            }
        }
Example #4
0
        /// <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();
        }
Example #5
0
        /// <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();
        }