コード例 #1
0
        /// <summary>
        /// Shows usual message box.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="isCancelButtonVisible">(Optional) Is cancel button visible?
        /// <para>By default is <see langword="false"/></para></param>
        /// <param name="isRightToLeft">(Optional) Is <see cref="FlowDirection"/>=<see cref="FlowDirection.RightToLeft"/>?
        /// <para>By default is <see langword="false"/></para></param>
        /// <returns><see cref="MessageBoxResult"/>.</returns>
        public static MessageBoxResult Show(string message, bool isCancelButtonVisible = false,
                                            bool isRightToLeft = false)
        {
            MaterialMessageBoxUserControl materialMessageBoxUserControl = new MaterialMessageBoxUserControl
            {
                MessageTextBlock = { Text = message },
                CancelButton     = { Visibility = isCancelButtonVisible ? Visibility.Visible : Visibility.Collapsed },
                FlowDirection    = isRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight
            };

            materialMessageBoxUserControl.OkButton.Focus();
            DialogHost.Show(materialMessageBoxUserControl);

            return(materialMessageBoxUserControl.Result);
        }
コード例 #2
0
        /// <summary>
        /// Shows error message box.
        /// </summary>
        /// <param name="message">The error message to display.</param>
        /// <param name="isCancelButtonVisible">(Optional) Is cancel button visible?
        /// <para>By default is <see langword="false"/></para></param>
        /// <param name="isRightToLeft">(Optional) Is <see cref="FlowDirection"/>=<see cref="FlowDirection.RightToLeft"/>?
        /// <para>By default is <see langword="false"/></para></param>
        /// <returns><see cref="MessageBoxResult"/>.</returns>
        public static async ValueTask <MessageBoxResult> ShowErrorAsync(string message,
                                                                        bool isCancelButtonVisible = false,
                                                                        bool isRightToLeft         = false)
        {
            MaterialMessageBoxUserControl materialMessageBoxUserControl = new MaterialMessageBoxUserControl
            {
                BorderBrush      = Brushes.Red, BorderThickness = new Thickness(2, 2, 2, 2),
                MessageTextBlock = { Text = message },
                CancelButton     = { Visibility = isCancelButtonVisible ? Visibility.Visible : Visibility.Collapsed },
                FlowDirection    = isRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight
            };

            materialMessageBoxUserControl.OkButton.Focus();
            await DialogHost.Show(materialMessageBoxUserControl).ConfigureAwait(false);

            return(materialMessageBoxUserControl.Result);
        }