Store apps and window sizing

The problem:

Similar to WPF Windows, for a Store app’s Page we can set Width, Height, MinWidth, and MinHeight attributes. However, in contrast to WPF, the Page.Width and Page.Height attributes only affect the size of the container that contains all of the page’s visual elements – the window the app is displayed in is not changed. Moreover, the Min... attributes do not affect the visual presentation in any way.

First of all, the reason for this behavior is that the Page object is not the root visual element, as it resides within a Frame which in turn is the content of the root Window. We can reconstruct this structure by looking at any Store App’s typical OnLaunched event handler: In most Apps, it will look similar to the following code snippet:

protected override void OnLaunched(LaunchActivatedEventArgs e)
	Frame rootFrame = Window.Current.Content as Frame;
	if (rootFrame.Content == null)

In this example, a new instance of MainPage is created and assigned as the content of the root window’s content frame, and then the window is shown on the screen. By adapting the page’s size attributes, obvisouly neither the containing frame nor the window are affected.

On the other hand, it is possible to directly access the root window’s Bounds property which represents its screen size and position, e.g.:

var width = Window.Current.Bounds.Width;

Unfortunately, this does not allow us to change the widow size neither, since Window.Bounds does not provide a (public) setter. The question is: How to define the minimum size of a Store App’s container window?

The solution(s):

For Windows 8/8.1 Apps, the answer is short since possibilities are quite limited: The app manifest requires the definition of the ApplicationView.MinWidth attribute:

MinWidth option

This limits us in three ways:

  • It allows to set the minimum width, but not height,
  • we can only choose between the two options 320px and 500px, and
  • this minimum width only applies when using the app in full-screen mode, if displayed in a window it does not affect the window size at all.

Compared to this, the UWP platform is more flexible: Although the MinWidth attribute has completely disappeared from the manifest, there are a few options available through the ApplicationView class, all to be set in C# code:

  • To set an App’s desired startup width, use the PreferredLaunchViewSize and PreferredLaunchWindowingMode properties:
    ApplicationView.PreferredLaunchViewSize = new Size(800, 600);
    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
  • To define an App’s minimum (window) size, use the SetPreferredMinSize method:
    ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 350));
  • Also resizing an App window during runtime from within C# code is possible:
    ApplicationView.GetForCurrentView().TryResizeView(new Size(1000, 600));

The platform gap:

The major shortcoming of the options listed above is that it’s not possible to affect a Windows 8 App’s size when running in window mode. The reason for this is historical: When the WinRT platform was released (good old Windows 8 times…), apps could only be started in full-screen mode. Running apps within windows is only possible in Windows 10, and together with the Windows 10 OS the UWP development platform was released, allowing to manipulate an app’s container window (as shown above). Unfortunately, this does not help Windows 8 Apps that are still around (or that are still actively developed, e.g. to ensure downwards compatibility) – the only option is to upgrade to UWP and hope that all Windows 8 users will as well update soon!