Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1500
How to handle event when close the childWindow
posted

HI,

If I want to uncheck one checkbox when the childWindow close,  the checkbox on the main page.

please see the follow chart,

If clicks-on the [Cancel] button, I can handle this problem in the click-event.

But how to handle this problem when clicks-on the [X] button?

Parents
No Data
Reply
  • 355
    Verified Answer
    posted

    To address this I created my own base dialog class that inhertied from this control and created my own DialogClosing event:

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media.Effects;
    using Infragistics.Controls.Interactions;

    namespace CriticalPath.OnDemand.OnDemandManager.View {
      public class ModalDialogBase : XamDialogWindow {
        private ModalDialogBase() { }

        public ModalDialogBase(object content) {
          Content = content;
          WireupClosingEvent();
        }

        #region DialogClosing event
        public event EventHandler DialogClosing;
        /// <summary>
        /// Event fires when the NewWindowState property of the dialog is 'Hidden'.
        /// </summary>
        protected virtual void OnDialogClosing(object sender, EventArgs e) {
          if (DialogClosing != null)
            DialogClosing(this, e);
        }

        /// <summary>
        /// Wires up the custom event OnDialogClosing.
        /// </summary>
        private void WireupClosingEvent() {
          WindowStateChanging += (sender, e) => {
            if (e.NewWindowState == Infragistics.Controls.Interactions.WindowState.Hidden)
              OnDialogClosing(sender, e);
          };
        }
        #endregion

      }
    }

    I then can handle the event myself:

    private void OnLaunchEditMessageReceived(CourseLaunchEditMessage message) {
      var dialog = new ModalDialogBase(new CourseEdit()) {
        Height = 350,
        Width = 600,
        Header = "Edit Course Details"
      };

      // wire up dialog closing (so cancel)
      dialog.DialogClosing += (sender, e) => {
        LayoutRoot.Children.Remove(dialog);
        message.Execute(false);
      };

      // show dialog
      LayoutRoot.Children.Add(dialog);
    }

Children