#422 – Setting Minimum Height and Width on Rows and Columns in a Grid

You can set a minimum height for a row in a Grid using the MinHeight property.  You can also set the minimum width of a column using the MinWidth property.

In the example below, we set the minimum height of the first column, even though its Width is also set to Auto.  We also set the minimum of the 4th column, whose width is set to 1* (the same width as the 3rd column).

    <Grid ShowGridLines="True">
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
            <ColumnDefinition Width="Auto" MinWidth="100"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*" MinWidth="50"/>

When the application starts, the first column is already wider than its elements, because of its minimum width.  The 4th column is set to the same width as the 3rd, both of which are larger than the 4th column’s minimum width.

As we make the window narrower, the 4th column eventually reaches its minimum width and will not become any narrower.