I want to limit my App window Width to 800 px, is there any way to do so? I tried SizeChanged event by doing some logic hack but actually it's executing after the Size is changed. So there's little bit of UI throttling.
3 Answers
As far as I know, there is no way how to limit window size since your app could run in fullscreen mode when in table mode.
However, you can set MaxWidth and/or MaxHeight properties on any FrameworkElement, for example on a page.
I've set both the properties to 500 on the red page and you can see the result here:
Comments
There is built-in support only for the minimum window size limit.
For this use the ApplicationView.SetPreferredMinSize method, where you can set the preferred minimum height and width size of you window.
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(800, 800));
You need to call it in App.xaml.cs before Window.Current.Activate();
For the maximum there is no good way. I don't know better solution than call ApplicationView.TryResizeView method in the SizeChanged event.
