Fernando Sousa
Fernando Sousa

Reputation: 241

Minimum size of a window

I'm developing an UWP app and I would like to set a minimum window size (in desktop)

I've been looking and I do not know where this is done.

Upvotes: 1

Views: 2987

Answers (2)

Romasz
Romasz

Reputation: 29792

You can set some of 'Windows' properties in ApplicationView class. There is a method that allows to set the Minimum size of application window (desktop only) - SetPreferredMinSize. However, this accepts values only from certain range:

The smallest allowed minimum size is 192 x 48 effective pixels. The largest allowed minimum size is 500 x 500 effective pixels. If you set a value outside of these bounds, it is coerced to be within the allowed bounds.

To do what you want you will have to set it upon app launching:

ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(300, 300));

Note that you also can set a preferred launch size with other property:

ApplicationView.PreferredLaunchViewSize = new Size(600, 600);

Upvotes: 6

Anastasios Moraitis
Anastasios Moraitis

Reputation: 388

As you can see here you can use minWidth and minHeight properties in the xaml.

Upvotes: 0

Related Questions