Screens Class
Definition
Represents all screens available on a device.
public class Screens
Methods
| Name | Description |
|---|---|
| RequestScreenDetails | Asks underlying platform to provide detailed screen information. On some platforms it might include non-primary screens, as well as display names. |
| ScreenFromBounds | Retrieves a Screen for the display that contains the rectangle. |
| ScreenFromPoint | Retrieves a Screen for the display that contains the specified point. |
| ScreenFromTopLevel | Retrieves a Screen for the display that contains the specified Avalonia.Controls.TopLevel. |
| ScreenFromVisual | Retrieves a Screen for the display that contains the specified Avalonia.Visual. |
| ScreenFromWindow | Retrieves 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
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
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
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
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
Exceptions
Properties
| Name | Description |
|---|---|
| All | Gets the list of all screens available on the device. |
| Primary | Gets the primary screen on the device. |
| ScreenCount | Gets 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
| Name | Description |
|---|---|
| Changed | Event raised when any screen was changed. |
Changed Event
Event raised when any screen was changed.
public event EventHandler Changed