public sealed record DesktopMessageBox : IEquatable<DesktopMessageBox> A native message box: a short message, optional detail and the buttons that answer it.
Parameters
MessageThe primary text, such as a question; not empty, without NUL.
Remarks
Show it through IDesktopMessageBoxes.ShowAsync of the window it belongs to. Use a native box where the page cannot answer, such as before it loaded or while it is busy, for close confirmations that must follow the platform's button order and keys, and for alerts a screen reader must announce as such; keep ordinary prompts in the page.
Rules, checked when the box is shown: at most six DesktopMessageBox.Buttons, each with a non-empty unique DesktopMessageBoxButton.Id and a label that is not blank, at most one DesktopMessageBoxButtonRole.Default and one DesktopMessageBoxButtonRole.Cancel button, and no text with NUL.
Constructors
DesktopMessageBox
public DesktopMessageBox(string Message) A native message box: a short message, optional detail and the buttons that answer it.
Parameters
MessageThe primary text, such as a question; not empty, without NUL.
Remarks
Show it through IDesktopMessageBoxes.ShowAsync of the window it belongs to. Use a native box where the page cannot answer, such as before it loaded or while it is busy, for close confirmations that must follow the platform's button order and keys, and for alerts a screen reader must announce as such; keep ordinary prompts in the page.
Rules, checked when the box is shown: at most six DesktopMessageBox.Buttons, each with a non-empty unique DesktopMessageBoxButton.Id and a label that is not blank, at most one DesktopMessageBoxButtonRole.Default and one DesktopMessageBoxButtonRole.Cancel button, and no text with NUL.
Properties
Buttons
public ImmutableArray<DesktopMessageBoxButton> Buttons { get; init; } The buttons, in the order of the application; empty, the default, shows one localized OK or Close button.
Remarks
Each platform places the buttons by role: Windows shows the DesktopMessageBoxButtonRole.Default button first and the DesktopMessageBoxButtonRole.Cancel button last, macOS the default button rightmost with the cancel button beside it, and GTK the default button last with the cancel button before it. Other buttons keep their order.
Detail
public string? Detail { get; init; } Secondary text below the message, such as what happens next; null for none.
Kind
public DesktopMessageBoxKind Kind { get; init; } The icon and alert level; DesktopMessageBoxKind.None by default.
Message
public string Message { get; init; } The primary text, such as a question; not empty, without NUL.
OwnerPolicy
public OwnerPolicy OwnerPolicy { get; init; } The required ownership: OwnerPolicy.RequireOwner, the default, shows the box only modal to its window; OwnerPolicy.PreferOwner also shows it without one where the services can.
Title
public string? Title { get; init; } The window title, where the box has one: the caption on Windows and the title on GTK 3.
Remarks
macOS sheets and GTK 4 alert dialogs have no title and ignore it. On Windows, null takes the owner window's title.