Table of Contents

Class MessageBox

Namespace
Wpf.Ui.Controls
Assembly
Wpf.Ui.dll

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

DependencyProperty

CloseButtonIconProperty

Identifies the CloseButtonIcon dependency property.

public static readonly DependencyProperty CloseButtonIconProperty

Field Value

DependencyProperty

CloseButtonTextProperty

Identifies the CloseButtonText dependency property.

public static readonly DependencyProperty CloseButtonTextProperty

Field Value

DependencyProperty

IsPrimaryButtonEnabledProperty

Identifies the IsPrimaryButtonEnabled dependency property.

public static readonly DependencyProperty IsPrimaryButtonEnabledProperty

Field Value

DependencyProperty

IsSecondaryButtonEnabledProperty

Identifies the IsSecondaryButtonEnabled dependency property.

public static readonly DependencyProperty IsSecondaryButtonEnabledProperty

Field Value

DependencyProperty

PrimaryButtonAppearanceProperty

Identifies the PrimaryButtonAppearance dependency property.

public static readonly DependencyProperty PrimaryButtonAppearanceProperty

Field Value

DependencyProperty

PrimaryButtonIconProperty

Identifies the PrimaryButtonIcon dependency property.

public static readonly DependencyProperty PrimaryButtonIconProperty

Field Value

DependencyProperty

PrimaryButtonTextProperty

Identifies the PrimaryButtonText dependency property.

public static readonly DependencyProperty PrimaryButtonTextProperty

Field Value

DependencyProperty

SecondaryButtonAppearanceProperty

Identifies the SecondaryButtonAppearance dependency property.

public static readonly DependencyProperty SecondaryButtonAppearanceProperty

Field Value

DependencyProperty

SecondaryButtonIconProperty

Identifies the SecondaryButtonIcon dependency property.

public static readonly DependencyProperty SecondaryButtonIconProperty

Field Value

DependencyProperty

SecondaryButtonTextProperty

Identifies the SecondaryButtonText dependency property.

public static readonly DependencyProperty SecondaryButtonTextProperty

Field Value

DependencyProperty

ShowTitleProperty

Identifies the ShowTitle dependency property.

public static readonly DependencyProperty ShowTitleProperty

Field Value

DependencyProperty

TemplateButtonCommandProperty

Identifies the TemplateButtonCommand dependency property.

public static readonly DependencyProperty TemplateButtonCommandProperty

Field Value

DependencyProperty

Properties

CloseButtonAppearance

Gets or sets the ControlAppearance on the close button

public ControlAppearance CloseButtonAppearance { get; set; }

Property Value

ControlAppearance

CloseButtonIcon

Gets or sets the SymbolRegular on the close button

public IconElement? CloseButtonIcon { get; set; }

Property Value

IconElement

CloseButtonText

Gets or sets the text to display on the close button.

public string CloseButtonText { get; set; }

Property Value

string

IsPrimaryButtonEnabled

Gets or sets a value indicating whether the MessageBox secondary button is enabled.

public bool IsPrimaryButtonEnabled { get; set; }

Property Value

bool

IsSecondaryButtonEnabled

Gets or sets a value indicating whether the MessageBox primary button is enabled.

public bool IsSecondaryButtonEnabled { get; set; }

Property Value

bool

PrimaryButtonAppearance

Gets or sets the ControlAppearance on the primary button

public ControlAppearance PrimaryButtonAppearance { get; set; }

Property Value

ControlAppearance

PrimaryButtonIcon

Gets or sets the SymbolRegular on the primary button

public IconElement? PrimaryButtonIcon { get; set; }

Property Value

IconElement

PrimaryButtonText

Gets or sets the text to display on the primary button.

public string PrimaryButtonText { get; set; }

Property Value

string

SecondaryButtonAppearance

Gets or sets the ControlAppearance on the secondary button

public ControlAppearance SecondaryButtonAppearance { get; set; }

Property Value

ControlAppearance

SecondaryButtonIcon

Gets or sets the SymbolRegular on the secondary button

public IconElement? SecondaryButtonIcon { get; set; }

Property Value

IconElement

SecondaryButtonText

Gets or sets the text to be displayed on the secondary button.

public string SecondaryButtonText { get; set; }

Property Value

string

ShowTitle

Gets or sets a value indicating whether to show the Title in TitleBar.

public bool ShowTitle { get; set; }

Property Value

bool

Tcs

protected TaskCompletionSource<MessageBoxResult>? Tcs { get; set; }

Property Value

TaskCompletionSource<MessageBoxResult>

TemplateButtonCommand

Gets the command triggered after clicking the button on the Footer.

public IRelayCommand TemplateButtonCommand { get; }

Property Value

IRelayCommand

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 MessageBoxButton

The MessageBox button

OnClosing(CancelEventArgs)

Raises the Closing event.

protected override void OnClosing(CancelEventArgs e)

Parameters

e CancelEventArgs

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

rootElement UIElement

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

showAsDialog bool
cancellationToken CancellationToken

Returns

Task<MessageBoxResult>

MessageBoxResult

Exceptions

TaskCanceledException

Thrown if the operation is canceled.