Get Screen Resolution in Win10 UWP App

Question!

As an UWP App runs in window mode on common desktop systems the "old" way of getting the screen resolution won't work anymore.

Old Resolution with Window.Current.Bounds was like shown in.

Is there another way to get the resolution of the (primary) display?



Answers

Just set a name for main Grid or Page and call its width or height for an element you want:

Element.Height = PagePane.Height;
Element.width = PagePane.Width;

it's the easiest way you can use!

By : Aminkhs


Use this method to get the screen size:

public static Size GetScreenResolutionInfo() 
{ 
    var applicationView = ApplicationView.GetForCurrentView(); 
    var displayInformation = DisplayInformation.GetForCurrentView(); 
    var bounds = applicationView.VisibleBounds; 
    var scale = displayInformation.RawPixelsPerViewPixel; 
    var size = new Size(bounds.Width * scale, bounds.Height * scale); 
    return size; 
} 

You should call this method from App.xaml.cs, after Window.Current.Activate(); in OnLaunched method.

Here's the sample code and you can download the full project.

By : Ann Yu


This video can help you solving your question :)
By: admin