如何使对话框(视图)在与主窗口相同的监视器上打开 [英] How to make a dialog(view) open up on the same monitor as the main window

查看:58
本文介绍了如何使对话框(视图)在与主窗口相同的监视器上打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有多台监视器的PC中,假设您运行的应用程序除了主窗口(例如选项")外还具有第二个窗口/对话框,您希望它在与相同的屏幕/监视器中打开MainWindow .如何强制这种行为?

In a PC with multiple monitors, say you run your application which have have a second Window/Dialog other than the main window (such as Options) that you want it to open in the same screen/monitor as your MainWindow. How to force this behavior?

您基本上想停止 MainWindow 在一台监视器上的情况,当您打开选项"页面时,它会显示在不同的屏幕/监视器上.

You basically want to stop the scenario that your MainWindow is on one monitor and when you bring up the "Options" page, it shows on a different screen/monitor.

推荐答案

您是否查看过 Window WindowStartupLocation 属性?

CenterScreen 将Window放置在包含光标的屏幕中央,通常应该没问题.例如,如果用户单击窗口"上的按钮并打开一个对话框,则光标仍将位于该按钮上方,因此该对话框将显示在同一窗口的中央.

CenterScreen places the Window in the center of the screen containing the cursor, which should normally be fine. For example, if a user clicks a button on your Window and a dialog opens, the cursor will still be over the button and thus the dialog will show up in the center of the same Window.

CenterOwner 将对话框放置在指定为其所有者的窗口的中央.声明类似于以下内容的新窗口:

CenterOwner places the Dialog in the center of the Window specified as it's owner. Declare the new Window similar to this:

MyDialog d = new MyDialog { Owner = parentWindow };
d.ShowDialog();

这篇关于如何使对话框(视图)在与主窗口相同的监视器上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆