WPF全屏应用程序 - 多个监视器

Ian*_*Ian 9 wpf multiple-monitors

我有多个与我的WPF应用程序一起使用的监视器.应用程序全屏运行,我希望能够在用户按下按钮时切换它所在的监视器.

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;
Run Code Online (Sandbox Code Playgroud)

我试图这样做,但是这个.Left总是有(-7)的值.我假设它不是让我设置它因为我是全屏,但我不是100%肯定.如何让它以全屏方式切换到另一台显示器?

Adr*_*ciu 4

作为一种破解,您可以更改窗口状态,将其发送到另一个监视器并将窗口状态更改回最大化:

this.WindowState = System.Windows.WindowState.Normal;
this.Left = screen.WorkingArea.Left;
this.Top = screen.WorkingArea.Top;
this.WindowState = System.Windows.WindowState.Maximized;
Run Code Online (Sandbox Code Playgroud)

它的作用不会产生任何不良效果。刚刚测试过这个。