This question already has an answer here:
这个问题在这里已有答案:
- How do I determine which monitor my .NET Windows Forms program is running on? 5 answers
如何确定运行.NET Windows Forms程序的监视器? 5个答案
I work on a WPF Application. I have two monitors connected to the same machine. I launch the application. How can I detect on which of the two screens the application is launched via code (C#)? Thanks!
我在WPF应用程序上工作。我有两台显示器连接到同一台机器。我启动了该应用程序。如何通过代码(C#)检测应用程序启动的两个屏幕中的哪一个?谢谢!
1 个解决方案
#1
Have you tried the Screen
class? To get the current screen use the static method FromControl
and pass your control as an argument. Then you can check the device name or Primary
property to detect if you are on the primary monitor.
你有没有尝试过Screen课程?要获取当前屏幕,请使用静态方法FromControl并将控件作为参数传递。然后,您可以检查设备名称或主要属性,以检测您是否在主监视器上。
#1
Have you tried the Screen
class? To get the current screen use the static method FromControl
and pass your control as an argument. Then you can check the device name or Primary
property to detect if you are on the primary monitor.
你有没有尝试过Screen课程?要获取当前屏幕,请使用静态方法FromControl并将控件作为参数传递。然后,您可以检查设备名称或主要属性,以检测您是否在主监视器上。