public sealed class DesktopSidePanel : IAsyncDisposable A page of a window's surface shown beside the window's page, in a strip on one edge by which the window grew (DesktopWindow.OpenSidePanelAsync).
Remarks
The window's page keeps its size and its position on the screen while the panel opens, closes, moves to the other edge or changes its width: the window grows or shrinks on the panel's edge in one native operation. When the user resizes the window the panel keeps its width and the page takes the rest, also when the window is maximized or full-screen.
Disposing it closes it.
Properties
Edge
public DesktopWindowEdge Edge { get; } Gets the edge the panel is on: DesktopWindowEdge.Left or DesktopWindowEdge.Right.
IsOpen
public bool IsOpen { get; } Gets whether the panel is open: false once it closed, for whatever reason.
Width
public int Width { get; } Gets the panel's width in device-independent pixels (points on macOS, logical pixels on Linux).
Methods
CloseAsync
public ValueTask CloseAsync(CancellationToken cancellationToken = default) Closes the panel: its page disconnects and the window shrinks back.
Parameters
cancellationTokenCancels waiting for the window; the close itself proceeds.
Returns
A task that completes when the panel has closed.
Exceptions
OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
When the user did not move or resize the window while the panel was open, the window gets back exactly the bounds it had before; otherwise its docked edge moves back by the panel's width. A maximized or full-screen window keeps its frame, the page takes the whole window, and the bounds it restores to shrink by the panel's width. Closing a closed panel does nothing.
DisposeAsync
public ValueTask DisposeAsync() Closes the panel, like DesktopSidePanel.CloseAsync.
Returns
A task that completes when the panel has closed.
FocusAsync
public ValueTask FocusAsync(CancellationToken cancellationToken = default) Moves the keyboard focus into the panel's page, to its focused element or its first one.
Parameters
cancellationTokenCancels waiting for the window.
Returns
A task that completes when the panel's view has the focus.
Exceptions
ObjectDisposedExceptionThe panel is closed.
OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Tab past the last element of the window's page focuses the panel's first one, and Shift+Tab before the first focuses the panel's last one; the panel hands the focus back the same way. This does not activate the window.
MoveToEdgeAsync
public ValueTask<DesktopSidePanelRefusal?> MoveToEdgeAsync(DesktopWindowEdge edge, CancellationToken cancellationToken = default) Moves the panel to the other edge: the window moves by the panel's width, and its page stays where it is on the screen.
Parameters
edgeThe new edge;
DesktopWindowEdge.StartandDesktopWindowEdge.EndfollowDesktopWindow.LayoutDirection.cancellationTokenCancels waiting for the window.
Returns
null when the panel is on that edge now, also when it already was; otherwise why it stayed, for the same reasons as DesktopWindow.OpenSidePanelAsync: the window is maximized, full-screen, snapped or minimized, the moved frame would leave the work area, or the platform cannot position windows.
Exceptions
ArgumentOutOfRangeExceptionedgeis not a defined value.ObjectDisposedExceptionThe panel is closed.
OperationCanceledExceptioncancellationTokenwas cancelled.
SetWidthAsync
public ValueTask<DesktopSidePanelRefusal?> SetWidthAsync(int width, CancellationToken cancellationToken = default) Changes the panel's width: the window grows or shrinks on the panel's edge by the difference, and its page keeps its size and position. Applications that let the user resize the panel offer their own control and call this.
Parameters
widthThe new width, in the units of
DesktopSidePanelOptions.Width.cancellationTokenCancels waiting for the window.
Returns
null when the panel has the width now; otherwise why it kept its width, for the same reasons as DesktopSidePanel.MoveToEdgeAsync.
Exceptions
ArgumentOutOfRangeExceptionwidthis smaller thanDesktopSidePanelOptions.MinimumWidth.ObjectDisposedExceptionThe panel is closed.
OperationCanceledExceptioncancellationTokenwas cancelled.
Events
Closed
public event EventHandler<DesktopSidePanelClosedEventArgs>? Closed Occurs once after the panel has closed, whatever closed it.
Remarks
Raised on the thread pool, never on the window's native thread, after DesktopSidePanel.IsOpen became false and the window shrank. A handler added after the panel closed is not called; check DesktopSidePanel.IsOpen after adding one. A handler that throws is logged (event 3041, SidePanelClosedHandlerFailed) and does not stop the other handlers.