Transform Screen.PrimaryScreen.WorkingArea to WPF dimensions at higher DPI settings

僤鯓⒐⒋嵵緔 提交于 2019-12-05 12:19:08

You get the transformed work area size from the SystemParameters.WorkArea property:

Top = 0;
Left = 0;
Width = System.Windows.SystemParameters.WorkArea.Width;
Height = System.Windows.SystemParameters.WorkArea.Height;

In WPF, you can use the SystemParameters.PrimaryScreenWidth and SystemParameters.PrimaryScreenHeight properties to find out the primary screen dimensions:

double width = SystemParameters.PrimaryScreenWidth;
double height = SystemParameters.PrimaryScreenHeight;
A.Holz

If you wanna get the dimensions of both Screens you simply can use:

var primaryScreen = 
   System.Windows.Forms
      .Screen
      .AllScreens
      .Where(s => s.Primary)
      .FirstOrDefault();

var secondaryScreen = 
   System.Windows.Forms
      .Screen
      .AllScreens
      .Where(s => !s.Primary)
      .FirstOrDefault();

After this you can reach Width, Height etc. by using

primaryScreen.Bounds.Width

So Long ;)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!