/// <summary>
        /// Creates an ExceptionDialog inside of the current window.
        /// </summary>
        /// <param name="window">The MetroWindow</param>
        /// <param name="title">The title of the MessageDialog.</param>
        /// <param name="ex">The exception to report.</param>
        /// <returns>A task promising the result of which button was pressed (Always Positive).</returns>
        public static Task<MessageDialogResult> ShowExceptionAsync(this MetroWindow window, string title, Exception ex)
        {
            window.Dispatcher.VerifyAccess();
            return HandleOverlayOnShow(null, window).ContinueWith(z =>
            {
                return (Task<MessageDialogResult>)window.Dispatcher.Invoke(new Func<Task<MessageDialogResult>>(() =>
                {
                    MetroDialogSettings settings = window.MetroDialogOptions;

                    //create the dialog control
                    var dialog = new ExceptionDialog(window, settings)
                    {
                        Message = ex.Message,
                        Title = title,
                        Ex = ex
                    };

                    SizeChangedEventHandler sizeHandler = SetupAndOpenDialog(window, dialog);
                    dialog.SizeChangedHandler = sizeHandler;

                    return dialog.WaitForLoadAsync().ContinueWith(x =>
                    {
                        if (DialogOpened != null)
                        {
                            window.Dispatcher.BeginInvoke(new Action(() => DialogOpened(window, new DialogStateChangedEventArgs())));
                        }

                        return dialog.WaitForButtonPressAsync().ContinueWith(y =>
                        {
                            //once a button as been clicked, begin removing the dialog.

                            dialog.OnClose();

                            if (DialogClosed != null)
                            {
                                window.Dispatcher.BeginInvoke(new Action(() => DialogClosed(window, new DialogStateChangedEventArgs())));
                            }

                            Task closingTask = (Task)window.Dispatcher.Invoke(new Func<Task>(() => dialog._WaitForCloseAsync()));
                            return closingTask.ContinueWith(a =>
                            {
                                return ((Task)window.Dispatcher.Invoke(new Func<Task>(() =>
                                {
                                    window.SizeChanged -= sizeHandler;

                                    window.metroDialogContainer.Children.Remove(dialog); //remove the dialog from the container

                                    return HandleOverlayOnHide(settings, window);
                                }))).ContinueWith(y3 => y).Unwrap();
                            });
                        }).Unwrap();
                    }).Unwrap().Unwrap();
                }));
            }).Unwrap();
        }
        //public static readonly DependencyProperty AffirmativeButtonTextProperty = DependencyProperty.Register("AffirmativeButtonText", typeof(string), typeof(MessageDialog), new PropertyMetadata("OK"));
        //public static readonly DependencyProperty NegativeButtonTextProperty = DependencyProperty.Register("NegativeButtonText", typeof(string), typeof(MessageDialog), new PropertyMetadata("Cancel"));
        //public static readonly DependencyProperty FirstAuxiliaryButtonTextProperty = DependencyProperty.Register("FirstAuxiliaryButtonText", typeof(string), typeof(MessageDialog), new PropertyMetadata("Cancel"));
        //public static readonly DependencyProperty SecondAuxiliaryButtonTextProperty = DependencyProperty.Register("SecondAuxiliaryButtonText", typeof(string), typeof(MessageDialog), new PropertyMetadata("Cancel"));
        //public static readonly DependencyProperty ButtonStyleProperty = DependencyProperty.Register("ButtonStyle", typeof(MessageDialogStyle), typeof(MessageDialog), new PropertyMetadata(MessageDialogStyle.Affirmative, new PropertyChangedCallback((s, e) =>
        //{
        //    ExceptionDialog md = (ExceptionDialog)s;
        //    SetButtonState(md);
        //})));
        private static void SetButtonState(ExceptionDialog md)
        {
            //if (md.PART_AffirmativeButton == null)
            //    return;

            //switch (md.ButtonStyle)
            //{
            //    case MessageDialogStyle.Affirmative:
            //    {
            md.PART_AffirmativeButton.Visibility = Visibility.Visible;
            //        md.PART_NegativeButton.Visibility = Visibility.Collapsed;
            //        md.PART_FirstAuxiliaryButton.Visibility = Visibility.Collapsed;
            //        md.PART_SecondAuxiliaryButton.Visibility = Visibility.Collapsed;
            //    }
            //    break;
            //    case MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary:
            //    case MessageDialogStyle.AffirmativeAndNegativeAndDoubleAuxiliary:
            //    case MessageDialogStyle.AffirmativeAndNegative:
            //    {
            //        md.PART_AffirmativeButton.Visibility = Visibility.Visible;
            //        md.PART_NegativeButton.Visibility = Visibility.Visible;

            //        if (md.ButtonStyle == MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary || md.ButtonStyle == MessageDialogStyle.AffirmativeAndNegativeAndDoubleAuxiliary)
            //        {
            //            md.PART_FirstAuxiliaryButton.Visibility = Visibility.Visible;
            //        }

            //        if (md.ButtonStyle == MessageDialogStyle.AffirmativeAndNegativeAndDoubleAuxiliary)
            //        {
            //            md.PART_SecondAuxiliaryButton.Visibility = Visibility.Visible;
            //        }
            //    }
            //    break;
            //}

            //md.AffirmativeButtonText = md.DialogSettings.AffirmativeButtonText;
            //md.NegativeButtonText = md.DialogSettings.NegativeButtonText;
            //md.FirstAuxiliaryButtonText = md.DialogSettings.FirstAuxiliaryButtonText;
            //md.SecondAuxiliaryButtonText = md.DialogSettings.SecondAuxiliaryButtonText;

            switch (md.DialogSettings.ColorScheme)
            {
                case MetroDialogColorScheme.Accented:
                    //md.PART_NegativeButton.Style = md.FindResource("HighlightedSquareButtonStyle") as Style;
                    //md.PART_FirstAuxiliaryButton.Style = md.FindResource("HighlightedSquareButtonStyle") as Style;
                    //md.PART_SecondAuxiliaryButton.Style = md.FindResource("HighlightedSquareButtonStyle") as Style;
                    break;
            }
        }