I'm running a background process (WindowsRuntimeComponent) and need to know the device (PC or Tablet) Aspect Ratio for cropping an image to fit the Lock Screen background. Is there a way to do this, seeing that it's a background process with nothing rendered on screen?
You can use this to get the required sizes
var bounds = Window.Current.Bounds;
double height = bounds.Height;
double width = bounds.Width;
Though while working with store app I found the following code to be working better as it adjust according to resolution
var width = Window.Current.Bounds.Width * (int)DisplayProperties.ResolutionScale / 100;
var height = Window.Current.Bounds.Height * (int)DisplayProperties.ResolutionScale / 100;
var dpi = DisplayInformation.GetForCurrentView().RawDpiY;
var screenDiagonal = Math.Sqrt(Math.Pow(width / dpi, 2) +Math.Pow(height / dpi, 2));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.