tags:

views:

142

answers:

3

In a C# application, how can I find out if a WPF window is in the primary monitor or another monitor?

+2  A: 

You can use the Screen.FromControl method to get the current screen for the current form like this:

Screen screen = Screen.FromControl(this);

Then you can check Screen.Primary to see if the current screen is the primary screen.

Andrew Hare
+2  A: 

If you're using windows forms, the following will work from any control.

bool isOnPrimaryMonitor = Screen.FromControl(this).Primary;
Jon Norton
A: 

Check out How do I find what screen the application is running on in C#
Also Run Application on a Dual Screen Environment has an interesting solution:

bool onPrimary = this.Bounds.IntersectsWith(Screen.PrimaryScreen.Bounds);

where "this" is the main form of your application.

SwDevMan81