Table of Contents

Class Screens

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

Represents all screens available on a device.

public class Screens
Inheritance
Screens
Inherited Members

Constructors

Screens(IScreenImpl)

Initializes a new instance of the Screens class.

[PrivateApi]
public Screens(IScreenImpl iScreenImpl)

Parameters

iScreenImpl IScreenImpl

Properties

All

Gets the list of all screens available on the device.

public IReadOnlyList<Screen> All { get; }

Property Value

IReadOnlyList<Screen>

Primary

Gets the primary screen on the device.

public Screen? Primary { get; }

Property Value

Screen

ScreenCount

Gets the total number of screens available on the device.

public int ScreenCount { get; }

Property Value

int

Methods

RequestScreenDetails()

Asks underlying platform to provide detailed screen information. On some platforms it might include non-primary screens, as well as display names.

public Task<bool> RequestScreenDetails()

Returns

Task<bool>

True, if detailed screen information was provided. False, if denied by the platform or user.

Remarks

This method is async and might show a dialog to the user asking for a permission.

ScreenFromBounds(PixelRect)

Retrieves a Screen for the display that contains the rectangle.

public Screen? ScreenFromBounds(PixelRect bounds)

Parameters

bounds PixelRect

Bounds that specifies the area for which to retrieve the display.

Returns

Screen

The Screen.

Remarks

On mobile, this method always returns null.

ScreenFromPoint(PixelPoint)

Retrieves a Screen for the display that contains the specified point.

public Screen? ScreenFromPoint(PixelPoint point)

Parameters

point PixelPoint

A Point that specifies the location for which to retrieve a Screen.

Returns

Screen

The Screen.

Remarks

On mobile, this method always returns null.

ScreenFromTopLevel(TopLevel)

Retrieves a Screen for the display that contains the specified TopLevel.

public Screen? ScreenFromTopLevel(TopLevel topLevel)

Parameters

topLevel TopLevel

The top level for which to retrieve the Screen.

Returns

Screen

The Screen.

Exceptions

ObjectDisposedException

TopLevel platform implementation was already disposed.

ScreenFromVisual(Visual)

Retrieves a Screen for the display that contains the specified Visual.

public Screen? ScreenFromVisual(Visual visual)

Parameters

visual Visual

A Visual for which to retrieve a Screen.

Returns

Screen

The Screen.

ScreenFromWindow(WindowBase)

Retrieves a Screen for the display that contains the specified WindowBase.

public Screen? ScreenFromWindow(WindowBase window)

Parameters

window WindowBase

The window for which to retrieve the Screen.

Returns

Screen

The Screen.

Exceptions

ObjectDisposedException

Window platform implementation was already disposed.

Events

Changed

Event raised when any screen was changed.

public event EventHandler? Changed

Event Type

EventHandler