#423 – Setting Maximum Height and Width for Rows and Columns in a Grid

In the same way that you can set minimum height and width of rows and columns in a Grid, you can also set the maximum height or width.

You set the maximum height of a row in a Grid using the MaxHeight property of a RowDefinition element.  You set the maximum width of a column by using the MaxWidth property of a ColumnDefinition element.

    <Grid ShowGridLines="True">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto" />
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
    	</Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MaxWidth="20"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*" MaxWidth="80"/>
        </Grid.ColumnDefinitions>


Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #423 – Setting Maximum Height and Width for Rows and Columns in a Grid

  1. Pingback: Dew Drop – November 4, 2011 | Alvin Ashcraft's Morning Dew

  2. Pingback: #429 – Child Element Properties that Affect Layout « 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: