InitializeMessageBox() protected method

Initializes the MessageBox.
protected InitializeMessageBox ( Window owner, string text, string caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult ) : void
owner System.Windows.Window
text string The text.
caption string The caption.
button MessageBoxButton The button.
image MessageBoxImage The image.
defaultResult MessageBoxResult
return void
示例#1
0
        /// <summary>
        /// Shows the MessageBox.
        /// </summary>
        /// <param name="messageText">The message text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="button">The button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        private static MessageBoxResult ShowCore(Window owner, IntPtr ownerHandle, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle)
        {
            if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
            {
                throw new InvalidOperationException("Static methods for MessageBoxes are not available in XBAP. Use the instance ShowMessageBox methods instead.");
            }

            if ((owner != null) && (ownerHandle != IntPtr.Zero))
            {
                throw new NotSupportedException("The owner of a MessageBox can't be both a Window and a WindowHandle.");
            }

            var msgBox = new MessageBox();

            msgBox.InitializeMessageBox(owner, ownerHandle, messageText, caption, button, icon, defaultResult);

            // Setting the style to null will inhibit any implicit styles
            if (messageBoxStyle != null)
            {
                msgBox.Style = messageBoxStyle;
            }

            msgBox.ShowDialog();
            return(msgBox.MessageBoxResult);
        }
        /// <summary>
        /// Shows the MessageBox.
        /// </summary>
        /// <param name="messageText">The message text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="button">The button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        private static MessageBoxResult ShowCore(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
        {
            MessageBox msgBox = new MessageBox();

            msgBox.InitializeMessageBox(owner, messageText, caption, button, icon, defaultResult);
            msgBox.Show();
            return(msgBox.MessageBoxResult);
        }
示例#3
0
        /// <summary>
        /// Shows the MessageBox.
        /// </summary>
        /// <param name="messageText">The message text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="button">The button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        private static MessageBoxResult ShowCore(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle)
        {
            MessageBox msgBox = new MessageBox();

            msgBox.InitializeMessageBox(owner, messageText, caption, button, icon, defaultResult);

            // Setting the style to null will inhibit any implicit styles
            if (messageBoxStyle != null)
            {
                msgBox.Style = messageBoxStyle;
            }

            msgBox.Show();
            return(msgBox.MessageBoxResult);
        }
    /// <summary>
    /// Shows the MessageBox.
    /// </summary>
    /// <param name="messageText">The message text.</param>
    /// <param name="caption">The caption.</param>
    /// <param name="button">The button.</param>
    /// <param name="icon">The icon.</param>
    /// <param name="defaultResult">The default result.</param>
    /// <returns></returns>
    private static MessageBoxResult ShowCore( Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle )
    {
      if( System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted )
      {
        throw new InvalidOperationException( "Static methods for MessageBoxes are not available in XBAP. Use the instance ShowMessageBox methods instead." );
      }

      MessageBox msgBox = new MessageBox();
      msgBox.InitializeMessageBox( owner, messageText, caption, button, icon, defaultResult );

      // Setting the style to null will inhibit any implicit styles      
      if( messageBoxStyle != null )
      {
        msgBox.Style = messageBoxStyle;
      }

      msgBox.ShowDialog();
      return msgBox.MessageBoxResult;
    }
示例#5
0
 /// <summary>
 /// Shows the MessageBox.
 /// </summary>
 /// <param name="messageText">The message text.</param>
 /// <param name="caption">The caption.</param>
 /// <param name="button">The button.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultResult">The default result.</param>
 /// <returns></returns>
 private static MessageBoxResult ShowCore( Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult )
 {
   MessageBox msgBox = new MessageBox();
   msgBox.InitializeMessageBox( owner, messageText, caption, button, icon, defaultResult );
   msgBox.Show();
   return msgBox.MessageBoxResult;
 }