2015-10-29 122 views

回答

0
var bounds = Window.Current.Bounds; 
    double w = bounds.Width; 
    double h = bounds.Height; 
    switch (DisplayProperties.ResolutionScale) 
    { 
     case ResolutionScale.Scale140Percent: 
      w = Math.Ceiling(w * 1.4); 
      h = Math.Ceiling(h * 1.4); 
      break; 
     case ResolutionScale.Scale180Percent: 
      w = Math.Ceiling(w * 1.8); 
      h = Math.Ceiling(h * 1.8); 
      break; 
    } 

    Size resolution = new Size(w, h); 

答案从这里取:link 这里:link

+0

此代码给我的决议,我想是在英寸屏幕的大小。我在空白的应用程序中运行这个代码,并得到错误的解决方案 - 我认为这是因为它基于Window.Current.Bounds - 这是我当前的Windows应用程序的尺寸,而不是我的屏幕尺寸。 –

+0

你可以得到这样的DPI: Windows.Graphics.Display.DisplayProperties.LogicalDpi 然后计算大小: pixles/DPI = Inches – GenericTeaCup