What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea for the monitor that the window is currently on.
Clairification: The window in question is WPF, not WinForms.
What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea for the monitor that the window is currently on.
Clairification: The window in question is WPF, not WinForms.
Screen.FromControl
, Screen.FromPoint
and Screen.FromRectangle
should help you with this. For example in WinForms it would be:
class MyForm : Form
{
public Rectangle GetScreen()
{
return Screen.FromControl(this).Bounds;
}
}
I don't know of an equivalent call for WPF. Therefore, you need to do something like this extension method.
static class ExtensionsForWPF
{
public static System.Windows.Forms.Screen GetScreen(this Window window)
{
return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle);
}
}
You can use this:
System.Windows.SystemParameters.WorkArea
This is also usefull:
System.Windows.SystemParameters.PrimaryScreenWidth
System.Windows.SystemParameters.PrimaryScreenHeight
Also you may need:
SystemParameters.VirtualScreenWidth
SystemParameters.VirtualScreenHeight
to get the combined size of all monitors and not one in particular.