Is there a way I can detect the resolution of the screen in a Windows 8 app so that I can scale and resize the elements of the UI accordingly?
If not then what is the best way to go about developing an app that is resolution independent? Is there a standard way that I am not aware of or is there some other way this can be achieved?
Anything that inherits from FrameworkElement has a SizeChanged event. This event returns the current size of the framework element.
To get the overall size of the screen you can use:
Windows.UI.Xaml.Window.Current.Bounds.Height
Windows.UI.Xaml.Window.Current.Bounds.Width
Be careful as this will return the size of the screen and you will need to take into account whether your app is full-screen or Snapped/Filled.
Microsoft guidance says that you should be avoiding absolute values for height/width and simply setting HorizontalAlignment and VerticalAlignment to Stretch to allow the UI to take as much space as it needs to render.
Anything these two articles don't explain?
Windows.Graphics.Display.DisplayProperties.LogicalDpi
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.