public sealed class DesktopWindowPlatformServices : IWindowPlatformServices, IPlatformCapabilities, IFileDialogs, IDesktopClipboard, ITextClipboard, IDesktopFileLauncher, IAsyncDisposable The platform services of one Desktop window, bound to its native owner once the window opens.
Remarks
DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance per window scope. Before the window opens every service reports PlatformUnavailableReason.OwnerUnavailable; OpenWindowAsync on RunicDesktopHost binds it to the window as soon as the presentation opens, and closing the window stops it; DesktopPlatformServices.AttachWindowServices does the same for a window the application opened itself. After that every service reports PlatformUnavailableReason.OwnerClosed.
Properties
Clipboard
public ITextClipboard Clipboard { get; } The window's clipboard, used through the window's native thread.
Remarks
Also an IDesktopClipboard; the instance stays the same before, while and after the window is open.
Documentation from IWindowPlatformServices.Clipboard.
FileDialogs
public IFileDialogs FileDialogs { get; } File and directory dialogs owned by the window.
Documentation from IWindowPlatformServices.FileDialogs.
FileLauncher
public IDesktopFileLauncher FileLauncher { get; } Hands local files and web, mail or Windows Settings URIs to native applications on behalf of the window.
Documentation from IWindowPlatformServices.FileLauncher.
MessageBoxes
public IDesktopMessageBoxes MessageBoxes { get; } Native message boxes owned by the window (PlatformCapabilityIds.MessageBoxes).
Remarks
Task dialogs on Windows, also for a WPF window, sheets on macOS, and GTK message or alert dialogs on Linux, once the window opens. Before that they report PlatformUnavailableReason.OwnerUnavailable, and after these services stop PlatformUnavailableReason.OwnerClosed; stopping closes a box that is shown. The instance stays the same, so a ViewModel can keep it from its constructor.
Documentation from IWindowPlatformServices.MessageBoxes.
Monitors
public IDesktopMonitors Monitors { get; } The desktop's monitors, in the units of the window's position and size (PlatformCapabilityIds.Monitors).
Remarks
The monitors of the window's host once the window opens: DesktopHost.Monitors for a Desktop window, and those of Windows for a WPF window. Before that they report PlatformUnavailableReason.OwnerUnavailable, and after these services stop PlatformUnavailableReason.OwnerClosed. The instance stays the same, so a ViewModel can keep it from its constructor; a watch follows the monitors it had when it started, so start one after the window opened.
Documentation from IWindowPlatformServices.Monitors.
Provider
public DesktopPlatformProvider Provider { get; } Gets the provider selected when the window opened, or DesktopPlatformProvider.None before that.
Methods
AnnounceAsync
public ValueTask<PlatformResult<PlatformUnit>> AnnounceAsync(string message, DesktopAnnouncementPriority priority = (DesktopAnnouncementPriority)0, CancellationToken cancellationToken = default) Asks the screen reader to announce a message for the window, such as the result of an action.
Parameters
messageThe text to speak, in the page's language.
priorityWhether the message waits for what the screen reader is saying, the default, or interrupts it.
cancellationTokenCancels before the request reaches the window.
Exceptions
ArgumentExceptionmessageis empty or white space.
Remarks
Announces as DesktopPlatformServices.AnnounceAsync does, with the same results. Before the window opens it reports PlatformUnavailableReason.OwnerUnavailable, and after these services stop PlatformUnavailableReason.OwnerClosed. The services of a WPF window, from WpfPlatformServices.ForWindow, announce through the window's UI Automation peer. IWindowPlatformServices.AnnounceAsync announces the same way, with PlatformAnnouncementPriority.
DisposeAsync
public ValueTask DisposeAsync() Stops the services: waits for platform operations, then releases file access the window still owns.
GetSnapshot
public CapabilitySnapshot GetSnapshot() Captures the current capability statuses.
Remarks
The menu capabilities follow the Desktop window, whose menus need no platform provider.
Documentation from IPlatformCapabilities.GetSnapshot.