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」になります。