1

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.

1
  • Limit, meaning, it'll be the maximum width? Commented Mar 16, 2017 at 9:06

3 Answers 3

2

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:

Example

Sign up to request clarification or add additional context in comments.

Comments

2

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.

1 Comment

That will not work, as maximum size that SetPreferredMinSize accept is 500*500
0

In this source is example how resize view.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.