WPF 全屏应用程序 - 多显示器
我的 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;
我试图这样做,但是 this.Left 的值始终为 (-7)。我假设它不允许我设置它,因为我是全屏的,但我不能 100% 确定。如何让它全屏切换到另一台显示器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一种黑客,您可以更改窗口状态,将其发送到另一个监视器并将窗口状态更改回最大化:
它可以正常工作,不会产生任何不良效果。刚刚测试过这个。
As a hack, you can change the window state, send it to the other monitor and change the window state back to maximized:
It works without any undesired effect. Just tested this.