Another (paraphrased) question from twitter “How do I set the minimum and maximum sizes for my window in WPF”. The poster wanted to know how to constrain the size of their WPF window to a set minimum height/width and maximum height/width.
I originally replied with a complex answer referring back to my WPF Resize Behavior, because I completely forgot about the simple supported approach:
<Window x:Class="WpfApplication21.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525"
MinHeight="300"
MinWidth="500"
MaxHeight="700"
MaxWidth="900">
<Grid>
</Grid>
</Window>
The above markup constrains the size of the window to the sizes indicated by using the MinHeight, MinWidth, MaxHeight and MaxWidth properties. You can also set these from code at runtime.
Use this sparingly. It is generally not a great practice to constrain the size of your application window, or at least not the max size.