What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea
for the monitor that the window is currently on.
Clarification: The window in question is WPF
, not WinForm
.
What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea
for the monitor that the window is currently on.
Clarification: The window in question is WPF
, not WinForm
.
Screen.FromControl
,Screen.FromPoint
andScreen.FromRectangle
should help you with this. For example in WinForms it would be:I don't know of an equivalent call for WPF. Therefore, you need to do something like this extension method.
Add on to ffpf
Adding a solution that doesn't use WinForms but NativeMethods instead. First you need to define the native methods needed.
And then get the monitor handle and the monitor info like this.
This is a "Center Screen DotNet 4.5 solution", using SystemParameters instead of System.Windows.Forms or My.Compuer.Screen: Since Windows 8 has changed the screen dimension calculation, the only way it works for me looks like that (Taskbar calculation included):