Search code examples
windows-8windows-store-appswindows-8.1win-universal-appwindows-10

Remove the height limit of an app targeting Windows 8.1, but running on Windows 10?


My question sounds simple: is it possible to remove the height limit of an app, if it is targeting Windows 8.1, but is also distributed to Windows 10 devices? Or is it my only choice just to upgrade project to target Windows 10, and distribute a separate package for it?

A related question: How to specify initial window size for Windows 8.1 app running on Windows 10

..and an answer suggests "You could use reflection to call part of windows 10 sdk at runtime within your windows 8.1 app". Well, I have turned the whole Internet inside out, and I didn't find any normal explanation of this mystical method.


Solution

  • The method you've mentioned is use reflection to call ApplicationView.SetPreferredMinSize method at run time within Windows 8.1 app like following:

    var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
    var setPreferredMinSizeMethod = appView.GetType().GetRuntimeMethod("SetPreferredMinSize", new Type[] { typeof(Size) });
    
    if (setPreferredMinSizeMethod != null)
    {
        setPreferredMinSizeMethod.Invoke(appView, new object[] { new Size(300, 300) });
    }
    

    Using this approach, you can reset the preferred min size and remove the default 768 height limit.
    enter image description here

    But please note that on Windows 10, Windows 8.1 app's ApplicaitonView is mainly controlled by system. If not necessary, please do not use reflection to do this.