Skip to main content

Screens Class

Definition​

Assembly:Avalonia.Controls
Package:Avalonia
Source:Screens.cs

Represents all screens available on a device.

public class Screens

Inheritance: object -> Screens

Methods​

NameDescription
RequestScreenDetailsAsks underlying platform to provide detailed screen information. On some platforms it might include non-primary screens, as well as display names.
ScreenFromBoundsRetrieves a Screen for the display that contains the rectangle.
ScreenFromPointRetrieves a Screen for the display that contains the specified point.
ScreenFromTopLevelRetrieves a Screen for the display that contains the specified Avalonia.Controls.TopLevel.
ScreenFromVisualRetrieves a Screen for the display that contains the specified Avalonia.Visual.
ScreenFromWindowRetrieves a Screen for the display that contains the specified Avalonia.Controls.WindowBase.

RequestScreenDetails Method​

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

public System.Threading.Tasks.Task<bool> RequestScreenDetails()

Returns​

System.Threading.Tasks.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 Method​

Retrieves a Screen for the display that contains the rectangle.

public Avalonia.Platform.Screen ScreenFromBounds(Avalonia.PixelRect bounds)

Parameters​

bounds Avalonia.PixelRect

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

Returns​

Avalonia.Platform.Screen

The Avalonia.Platform.Screen.

Remarks​

On mobile, this method always returns null.

ScreenFromPoint Method​

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

public Avalonia.Platform.Screen ScreenFromPoint(Avalonia.PixelPoint point)

Parameters​

point Avalonia.PixelPoint

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

Returns​

Avalonia.Platform.Screen

The Avalonia.Platform.Screen.

Remarks​

On mobile, this method always returns null.

ScreenFromTopLevel Method​

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

public Avalonia.Platform.Screen ScreenFromTopLevel(Avalonia.Controls.TopLevel topLevel)

Parameters​

topLevel Avalonia.Controls.TopLevel

The top level for which to retrieve the Screen.

Returns​

Avalonia.Platform.Screen

The Avalonia.Platform.Screen.

Exceptions​

ScreenFromVisual Method​

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

public Avalonia.Platform.Screen ScreenFromVisual(Avalonia.Visual visual)

Parameters​

visual Avalonia.Visual

A Visual for which to retrieve a Screen.

Returns​

Avalonia.Platform.Screen

The Avalonia.Platform.Screen.

ScreenFromWindow Method​

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

public Avalonia.Platform.Screen ScreenFromWindow(Avalonia.Controls.WindowBase window)

Parameters​

window Avalonia.Controls.WindowBase

The window for which to retrieve the Screen.

Returns​

Avalonia.Platform.Screen

The Avalonia.Platform.Screen.

Exceptions​

Properties​

NameDescription
AllGets the list of all screens available on the device.
PrimaryGets the primary screen on the device.
ScreenCountGets the total number of screens available on the device.

All Property​

Gets the list of all screens available on the device.

public System.Collections.Generic.IReadOnlyList<Avalonia.Platform.Screen> All { get; set; }

Primary Property​

Gets the primary screen on the device.

public Avalonia.Platform.Screen Primary { get; set; }

ScreenCount Property​

Gets the total number of screens available on the device.

public int ScreenCount { get; set; }

Events​

NameDescription
ChangedEvent raised when any screen was changed.

Changed Event​

Event raised when any screen was changed.

public event EventHandler Changed