有没有办法在 WinRt 应用程序中获取屏幕分辨率?我知道在 windows phone 中是可能的:
var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
var bounds = Window.Current.Bounds;
var x = (int) (bounds.Width*scaleFactor);
var y = (int) (bounds.Height*scaleFactor);
var resolution = String.Format("{0}x{1}", Math.Max(x, y),Math.Min(x,y));
But in winrt I don't have the RawPixelsPerViewPixel method...
有任何想法吗?
我尝试遵循Windows 8.1 商店应用程序帖子中的检测屏幕缩放因子:
ResolutionScale resolutionScale = DisplayInformation.GetForCurrentView().ResolutionScale;
double scale = (double)resolutionScale / 100.0;
var bounds = Window.Current.Bounds;
var x = (int)(bounds.Width * scale ) ;
var y = (int)(bounds.Height * scale );
var resolution = String.Format("{0}x{1}", Math.Max(x, y), Math.Min(x,y) );
但是我得到了错误的数字,对于分辨率 1920 x 1080,我得到“1920x1008”,对于分辨率 800 x 600,我得到“1126x743”