I've got multiple monitors that are being used with my WPF application. The application runs full screen, and I want to be able to switch which monitor it's on when the user presses a button.
case Key.M:
var allScreens = System.Windows.Forms.Screen.AllScreens.ToList();
if (this.CurrentScreen < allScreens.Count - 1)
{
this.CurrentScreen++;
}
else { this.CurrentScreen = 0; }
this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
this.Top = allScreens[this.CurrentScreen].Bounds.Top;
this.Left = allScreens[this.CurrentScreen].Bounds.Left;
break;
I'm trying to do this like so, but this.Left always has the value of (-7). I'm assuming it's not letting my set it because I'm full screen, but I'm not 100% sure. How can I get it to switch to the other monitor in fullscreen?
As a hack, you can change the window state, send it to the other monitor and change the window state back to maximized:
this.WindowState = System.Windows.WindowState.Normal;
this.Left = screen.WorkingArea.Left;
this.Top = screen.WorkingArea.Top;
this.WindowState = System.Windows.WindowState.Maximized;
It works without any undesired effect. Just tested this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With