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 CloseButtonAppearanceProperty
Field Value
CloseButtonIconProperty
Identifies the CloseButtonIcon dependency property.
public static readonly DependencyProperty CloseButtonIconProperty
Field Value
CloseButtonTextProperty
Identifies the CloseButtonText dependency property.
public static readonly DependencyProperty CloseButtonTextProperty
Field Value
IsPrimaryButtonEnabledProperty
Identifies the IsPrimaryButtonEnabled dependency property.
public static readonly DependencyProperty IsPrimaryButtonEnabledProperty
Field Value
IsSecondaryButtonEnabledProperty
Identifies the IsSecondaryButtonEnabled dependency property.
public static readonly DependencyProperty IsSecondaryButtonEnabledProperty
Field Value
PrimaryButtonAppearanceProperty
Identifies the PrimaryButtonAppearance dependency property.
public static readonly DependencyProperty PrimaryButtonAppearanceProperty
Field Value
PrimaryButtonIconProperty
Identifies the PrimaryButtonIcon dependency property.
public static readonly DependencyProperty PrimaryButtonIconProperty
Field Value
PrimaryButtonTextProperty
Identifies the PrimaryButtonText dependency property.
public static readonly DependencyProperty PrimaryButtonTextProperty
Field Value
SecondaryButtonAppearanceProperty
Identifies the SecondaryButtonAppearance dependency property.
public static readonly DependencyProperty SecondaryButtonAppearanceProperty
Field Value
SecondaryButtonIconProperty
Identifies the SecondaryButtonIcon dependency property.
public static readonly DependencyProperty SecondaryButtonIconProperty
Field Value
SecondaryButtonTextProperty
Identifies the SecondaryButtonText dependency property.
public static readonly DependencyProperty SecondaryButtonTextProperty
Field Value
ShowTitleProperty
Identifies the ShowTitle dependency property.
public static readonly DependencyProperty ShowTitleProperty
Field Value
TemplateButtonCommandProperty
Identifies the TemplateButtonCommand dependency property.
public static readonly DependencyProperty TemplateButtonCommandProperty
Field 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
IsPrimaryButtonEnabled
Gets or sets a value indicating whether the MessageBox secondary button is enabled.
public bool IsPrimaryButtonEnabled { get; set; }
Property Value
IsSecondaryButtonEnabled
Gets or sets a value indicating whether the MessageBox primary 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
button
MessageBoxButtonThe MessageBox button
OnClosing(CancelEventArgs)
Raises the Closing event.
protected override void OnClosing(CancelEventArgs e)
Parameters
e
CancelEventArgsA 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
rootElement
UIElementThe 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
showAsDialog
boolcancellationToken
CancellationToken
Returns
Exceptions
- TaskCanceledException
Thrown if the operation is canceled.