Adaptive screen Sizing of your Windows 10 Universal Application

Adaptive screen Sizing of your Windows 10 Universal Application

In Windows 10 Universal Application we know the APP can be opened at any width and any height. But as a developer if you want to restrict, this can be handle from your code.   There are few set of API’s using which you can set the initial size, max limit and few more stuff.

Windows 10 App

Launching in Preferred Size

If you want app to be opened at a preferred height and width then you can set the preferred size for the app by setting the size object to the PreferredLaunchViewSize property and set the  ApplicationViewWindowingMode.PreferredLaunchViewSize to PreferredLaunchViewSize.

ApplicationView.PreferredLaunchViewSize = new Size { Height = 600, Width = 600 };
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

This code launches the App with height 600 and width 600.


Launching in FullScreen.
If the you want the App to be launched in the full screen in Windows 10, you can you following code snippet.

ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;

This App opens in the full screen when ever launched.

Setting the Minimum Size for the APP.
We can resize the app to a very small width and height in windows 10. But sometimes smaller screen sizes may not be useful for some apps. So in that case the developer can set the minimum size the app needs in order to display the content. Developer can set the app to have a minimum size using the following API.

ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size{ Height = 400, Width = 600 });

Resizing the APP
There may be a case where the screen width will not be enough to display a content in that case the developer can use the following API to change the size of the app from code.

ApplicationView.GetForCurrentView().TryResizeView(new Size{Width = 800, Height = 600 });

This code may change the size of the app as per the size available.
Hope this post helps in creating universal app for the adaptive screen sized.

Arun Kumar

Arun kumar Surya Prakash, is a  Developer  Consultant. He  is a Microsoft Certified Solution  Developer  for Store App Development, and a Azure Solution Developer. His core skills is on developing Windows Store App and Cross Platform App development. You can follow him @arunnov04

7 Comments to “Adaptive screen Sizing of your Windows 10 Universal Application”

  1. This post is awesome!
    Unfortunately several APIs has been changed in 10240.

    ==> ApplicationView.PreferredLaunchViewSize = size;

    ==> ApplicationView.GetForCurrentView().TryResizeView(size)

    …and so on.

Comments are closed.