Skip to main content

How to: Work with screens

The Screens API provides information about connected monitors.

Accessing screens​

Access Screens from any TopLevel:

var screens = TopLevel.GetTopLevel(this)?.Screens;

Querying screens​

// All connected screens
var allScreens = screens.All;

// Primary monitor
var primary = screens.Primary;

// Screen containing a specific window
var currentScreen = screens.ScreenFromWindow(this);

// Screen at a point
var screenAtPoint = screens.ScreenFromPoint(new PixelPoint(500, 300));

Screen properties​

PropertyTypeDescription
BoundsPixelRectScreen dimensions in pixels.
WorkingAreaPixelRectUsable area in pixels. Excludes taskbars and docks.
ScalingdoubleDPI scaling factor (e.g., 1.0 for 96 DPI, 1.5 for 144 DPI).
IsPrimaryboolWhether this screen is the primary display.
DisplayNamestring?Display name reported by the operating system.
CurrentOrientationScreenOrientationScreen orientation, e.g., landscape, portrait.

Responding to screen changes​

Subscribe to the Changed event to detect when monitors are added, removed, or reconfigured.

screens.Changed += (sender, args) =>
{
// Re-evaluate window placement or layout
var count = screens.All.Count;
};

See also​