Wpf: Provide an equivalent for the WinForms Screen class

Created on 8 Oct 2019  路  2Comments  路  Source: dotnet/wpf

WPF generally doesn't include Windows Forms (the developer has to reference WinForms explicitly). We do this (among other reasons) so that we don't pollute IntelliSense with two UI stacks.

One common reason why people end up having to reference WinForms is so that they can enumerate screens and put windows on specific screens. But even with WinForms, the APIs aren't exactly super usable from WPF, due to mismatches in primitive types. It would be good if WPF would provide an equivalent type.

issue-type-enhancement

Most helpful comment

I think this class should also return values in WPF鈥檚 DPI independent units rather than a straight port of how these APIs work in WinForms, especially considering that the Left and Top properties on Window are also DPI independent.

All 2 comments

I think this class should also return values in WPF鈥檚 DPI independent units rather than a straight port of how these APIs work in WinForms, especially considering that the Left and Top properties on Window are also DPI independent.

For my case, user may have more than 3 monitors, and they are stacked and make the visible workarea as Polygon, instead of Rectangle.

Lacking Screen equivalent, WPF apps may not be able to tell whether window is actually visible in any monitors.

As illustrated below, if Window is position between monitor 4 & 5, then there are no existing APIs in pure WPF way, to tell window is invisible.

+-----+     +-----+
|  4  |     |  5  |
+-----+-----+-----+
|  1  |  2  |  3  |
+-----+-----+-----+
Was this page helpful?
0 / 5 - 0 ratings