public interface IDesktopMessageBoxes Native message boxes owned by one window.
Remarks
IWindowPlatformServices.MessageBoxes of a window, which a ViewModel can also take directly. Its capability is PlatformCapabilityIds.MessageBoxes. Methods are safe to call from any thread; the box is shown on the window's thread.
Methods
ShowAsync
ValueTask<PlatformResult<DesktopMessageBoxButton?>> ShowAsync(DesktopMessageBox messageBox, CancellationToken cancellationToken = default) Shows a message box modal to the window and returns the button the user chose.
Parameters
messageBoxThe box; see
DesktopMessageBoxfor its rules.cancellationTokenCloses the box, which then throws
OperationCanceledException.
Returns
Success with the chosen button, one of DesktopMessageBox.Buttons, or with null when the box had no buttons of the application or GTK closed it without a button, such as when the user pressed Esc in a box without a cancel button. Unavailable: PlatformUnavailableReason.OwnerUnavailable before the window opens or on a host without a native owner, PlatformUnavailableReason.OwnerClosed once it closed, also while the box is shown, and PlatformUnavailableReason.BackendUnavailable when the platform cannot show the box, such as GTK before 4.10.
Exceptions
ArgumentExceptionmessageBoxbreaks a rule.ArgumentNullExceptionmessageBoxisnull.OperationCanceledExceptioncancellationTokenwas cancelled.