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.
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.
Pingback: Dew Drop – July 28, 2015 (#2062) | Morning Dew
Pingback: How to display the back button in the Windows Universal APPs title bar ?
Pingback: .NET Tips and Tricks from Daily .NET Tips – ( Visual Studio 2015, Windows Universal App Development, Microsoft Band, Xamarin ) – July 2015 Links | Abhijit's World of .NET
Pingback: Visual Studio – Developer Top Ten for August 6th, 2015 - Dmitry Lyalin
This post is awesome!
Unfortunately several APIs has been changed in 10240.
ApplicationView.GetForCurrentView().SetPreferredlaunchViewSize(size)
==> ApplicationView.PreferredLaunchViewSize = size;
ApplicationView.GetForCurrentView().TryResize(size)
==> ApplicationView.GetForCurrentView().TryResizeView(size)
…and so on.
Thanks for the info biac.
I have updated the post as per the latest build.
Pingback: How to use Adaptive Tiles in Windows 10 Universal Apps.