0

how can I set a minimum size in an universal app (win 10) for the application window? in my project I have only object with Page tag, not Window. I want that the screen of the application can't be resized less off a certein value.

thanks a lot

luna80
  • 173
  • 2
  • 12

3 Answers3

0

In the Package.appxmanifest of a Windows 8.1 Universal app, you could set a minimum width, to one of 3 pre-defined values. Setting minimum values on your page will not prevent your application from resizing. Setting maximum values will not prevent resizing either, but it will result in black borders when the application frame is larger than your set dimension. It's worth mentioning that 320 px is the absolute minimum width on 8.1 and on Windows 10 (for phones).

In Windows 10 UWP this property is no longer available. You should AdaptiveTriggers to handle your UI layout on Windows 10.

If you want to check the minimum resize dimensions, keep the scaling of your pc in mind. My laptop scales at 125%, a screenshot of the minimum dimension for the desktop client is 627x441 (~500x350 at 100%) including the space used for the app bar. But it's more common to just use AdaptiveTrigger and 720 pixels as the cut-off between phone and tablet.

Bart
  • 9,925
  • 7
  • 47
  • 64
  • thanks a lot for the reply! but I don't have the minimum width option in package.appxmanifest – luna80 Oct 05 '15 at 12:17
  • You're totally right, I had a Windows 8.1 Universal app open as well and checked the wrong manifest file. Win10 no longer has this property and layout depending on resolution should be done with AdaptiveTriggers. – Bart Oct 05 '15 at 12:50
0

you are working on a universal app, you shouldn't set a minimum width . It should be working on every resolution and device.

you should instead use visual state manager and adaptive triggers.

best of luck !

Amine Da.
  • 1,124
  • 3
  • 14
  • 20
0

I came across this question in 2023, for WinUI 3 XAML.

If you can get access to the WndProc (which you can in WinUI 3 [and probably WPF], but not UWP), you can use that to set a minimum size for your app.

The recommended solution, implemented on GitHub, is to use P/Invoke to call the window subclassing functions SetWindowSubclass and DefSubclassProc:

  1. Write a static WndProc method that handles WM_GETMINMAXINFO, then forwards any other window messages to the original WndProc, via DefSubclassProc (or CallWindowProc in the examples), although note the disadvantages).
  2. Register your new WndProc via SetWindowSubclass (or SetWindowLongPtr in the examples).

This comes from an issue on the XAML GitHub repo.

See WinUI 3 How to set Minimum Size of a Window and WM_GETMINMAXINFO in WinUI 3 with C#?

citelao
  • 4,898
  • 2
  • 22
  • 36