/// <summary>
        /// Raises DismissPopup event
        /// </summary>
        public static void RaiseDismissPopupEvent(object sender, DismissPopupMode mode, DismissPopupReason reason = DismissPopupReason.Undefined)
        {
            var element = sender as UIElement;

            if (element == null)
            {
                return;
            }

            WriteDebug($"Dismissing Popup (Mode = {mode}, Sender = {sender})");

            element.RaiseEvent(new DismissPopupEventArgs(mode, reason));
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dismissMode">Dismiss mode.</param>
 /// <param name="reason">Dismiss reason.</param>
 public DismissPopupEventArgs(DismissPopupMode dismissMode, DismissPopupReason reason)
 {
     this.RoutedEvent   = PopupService.DismissPopupEvent;
     this.DismissMode   = dismissMode;
     this.DismissReason = reason;
 }
        /// <summary>
        /// Raises DismissPopup event (Async)
        /// </summary>
        public static void RaiseDismissPopupEventAsync(object sender, DismissPopupMode mode, DismissPopupReason reason = DismissPopupReason.Undefined)
        {
            var element = sender as UIElement;

            if (element == null)
            {
                return;
            }

            WriteDebug($"Dismissing Popup async (Mode = {mode}, Sender = {sender})");

            element.RunInDispatcherAsync(() => RaiseDismissPopupEvent(sender, mode, reason));
        }