Class MessageBox
Customized window for notifications.
public class MessageBox : Window, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, IAddChild- Inheritance
- 
      
      
      
      
      
      
      
      
      
      MessageBox
- Implements
- Inherited Members
Constructors
MessageBox()
Initializes a new instance of the MessageBox class.
public MessageBox()Fields
CloseButtonAppearanceProperty
Identifies the CloseButtonAppearance dependency property.
public static readonly DependencyProperty CloseButtonAppearancePropertyField Value
CloseButtonIconProperty
Identifies the CloseButtonIcon dependency property.
public static readonly DependencyProperty CloseButtonIconPropertyField Value
CloseButtonTextProperty
Identifies the CloseButtonText dependency property.
public static readonly DependencyProperty CloseButtonTextPropertyField Value
IsCloseButtonEnabledProperty
Identifies the IsCloseButtonEnabled dependency property.
public static readonly DependencyProperty IsCloseButtonEnabledPropertyField Value
IsPrimaryButtonEnabledProperty
Identifies the IsPrimaryButtonEnabled dependency property.
public static readonly DependencyProperty IsPrimaryButtonEnabledPropertyField Value
IsSecondaryButtonEnabledProperty
Identifies the IsSecondaryButtonEnabled dependency property.
public static readonly DependencyProperty IsSecondaryButtonEnabledPropertyField Value
PrimaryButtonAppearanceProperty
Identifies the PrimaryButtonAppearance dependency property.
public static readonly DependencyProperty PrimaryButtonAppearancePropertyField Value
PrimaryButtonIconProperty
Identifies the PrimaryButtonIcon dependency property.
public static readonly DependencyProperty PrimaryButtonIconPropertyField Value
PrimaryButtonTextProperty
Identifies the PrimaryButtonText dependency property.
public static readonly DependencyProperty PrimaryButtonTextPropertyField Value
SecondaryButtonAppearanceProperty
Identifies the SecondaryButtonAppearance dependency property.
public static readonly DependencyProperty SecondaryButtonAppearancePropertyField Value
SecondaryButtonIconProperty
Identifies the SecondaryButtonIcon dependency property.
public static readonly DependencyProperty SecondaryButtonIconPropertyField Value
SecondaryButtonTextProperty
Identifies the SecondaryButtonText dependency property.
public static readonly DependencyProperty SecondaryButtonTextPropertyField Value
ShowTitleProperty
Identifies the ShowTitle dependency property.
public static readonly DependencyProperty ShowTitlePropertyField Value
TemplateButtonCommandProperty
Identifies the TemplateButtonCommand dependency property.
public static readonly DependencyProperty TemplateButtonCommandPropertyField Value
Properties
CloseButtonAppearance
Gets or sets the ControlAppearance on the close button
public ControlAppearance CloseButtonAppearance { get; set; }Property Value
CloseButtonIcon
Gets or sets the SymbolRegular on the close button
public IconElement? CloseButtonIcon { get; set; }Property Value
CloseButtonText
Gets or sets the text to display on the close button.
public string CloseButtonText { get; set; }Property Value
IsCloseButtonEnabled
Gets or sets a value indicating whether the MessageBox close button is enabled.
public bool IsCloseButtonEnabled { get; set; }Property Value
IsPrimaryButtonEnabled
Gets or sets a value indicating whether the MessageBox primary button is enabled.
public bool IsPrimaryButtonEnabled { get; set; }Property Value
IsSecondaryButtonEnabled
Gets or sets a value indicating whether the MessageBox secondary button is enabled.
public bool IsSecondaryButtonEnabled { get; set; }Property Value
PrimaryButtonAppearance
Gets or sets the ControlAppearance on the primary button
public ControlAppearance PrimaryButtonAppearance { get; set; }Property Value
PrimaryButtonIcon
Gets or sets the SymbolRegular on the primary button
public IconElement? PrimaryButtonIcon { get; set; }Property Value
PrimaryButtonText
Gets or sets the text to display on the primary button.
public string PrimaryButtonText { get; set; }Property Value
SecondaryButtonAppearance
Gets or sets the ControlAppearance on the secondary button
public ControlAppearance SecondaryButtonAppearance { get; set; }Property Value
SecondaryButtonIcon
Gets or sets the SymbolRegular on the secondary button
public IconElement? SecondaryButtonIcon { get; set; }Property Value
SecondaryButtonText
Gets or sets the text to be displayed on the secondary button.
public string SecondaryButtonText { get; set; }Property Value
ShowTitle
public bool ShowTitle { get; set; }Property Value
Tcs
protected TaskCompletionSource<MessageBoxResult>? Tcs { get; set; }Property Value
TemplateButtonCommand
Gets the command triggered after clicking the button on the Footer.
public IRelayCommand TemplateButtonCommand { get; }Property Value
Methods
CenterWindowOnScreen()
protected virtual void CenterWindowOnScreen()Close()
[Obsolete("Use Close with MessageBoxResult instead")]
public void Close()OnButtonClick(MessageBoxButton)
Occurs after the MessageBoxButton is clicked
protected virtual void OnButtonClick(MessageBoxButton button)Parameters
- buttonMessageBoxButton
- The MessageBox button 
OnClosing(CancelEventArgs)
Raises the Closing event.
protected override void OnClosing(CancelEventArgs e)Parameters
- eCancelEventArgs
- A CancelEventArgs that contains the event data. 
OnLoaded()
Occurs after Loading event
protected virtual void OnLoaded()ResizeToContentSize(UIElement)
Resizes the MessageBox to fit the content's size, including margins.
protected virtual void ResizeToContentSize(UIElement rootElement)Parameters
- rootElementUIElement
- The root element of the MessageBox 
Show()
[Obsolete("Use ShowDialogAsync instead")]
public void Show()ShowDialog()
[Obsolete("Use ShowDialogAsync instead")]
public bool? ShowDialog()Returns
- bool?
ShowDialogAsync(bool, CancellationToken)
Displays a message box
public Task<MessageBoxResult> ShowDialogAsync(bool showAsDialog = true, CancellationToken cancellationToken = default)Parameters
- showAsDialogbool
- cancellationTokenCancellationToken
Returns
Exceptions
- TaskCanceledException
- Thrown if the operation is canceled.