Work@Microsoft    Study@UW.edu    Live@Seattle

Controlling the window size of UWP Windows 10 apps

Controlling the window size of UWP Windows 10 apps
5 (100%) 1 vote

1. Set the default window size when your UWP app launches on the desktop

The default launching window size of UWP Windows 10 apps on desktop is 500px (width) * 550px (height).

If you want the app to be launched at a preferred width and height, you can set the ApplicationView.PreferredLaunchViewSize property in the main window.

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();

// Set the preferred launch view size to 360 * 550
ApplicationView.PreferredLaunchViewSize = new Size { Height = 550, Width = 360 };
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
}

 

2. Change the minimum window size for window resizing

By default, the minimum window size for user to resize the window is 500px (width) * 320px (height).  Sometimes, this default value cannot satisfy the requirement. To change the minimum window size, you can use the ApplicationView.SetPreferredMinSize method.

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();

// Set the min size to 250 * 400
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size { Width = 250, Height = 400});
}

 

3. Launch the window in full screen

If you want your application to be launched in full screen mode, you can add the following code to the MainPage constructor.

ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;

 

4. Resize the window during the runtime

During the application runtime, you may want to programmatically enlarge the window size to display more content in the app.   ApplicationView.TryResizeView attempts to change the size of the view to the specified size.

ApplicationView.GetForCurrentView().TryResizeView(new Size{Width = 1000, Height = 550 });

 


Comments to Controlling the window size of UWP Windows 10 apps

  • Ex # 1. The size should be Width as the 1st parameter.

    Bob Smith October 30, 2015 4:36 pm Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...
ScottGe.net