This documentation is archived and is not being maintained.

RowDefinition.MaxHeight Property

Gets or sets a value that represents the maximum height of a RowDefinition.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public double MaxHeight { get; set; }
<object MaxHeight="double"/>
- or -
<object MaxHeight="qualifiedDouble"/>

XAML Values



String representation of a Double value equal to or greater than 0.0034 but equal to or less than 160000. An unqualified value is measured in device independent pixels. Strings need not explicitly include decimal points.


A double value as described above, (excepting Auto) followed by one of the following unit specifiers: px, in, cm, pt.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

cm is centimeters; 1cm==(96/2.54) px

pt is points; 1pt==(96/72) px

Property Value

Type: System.Double
A Double that represents the maximum height.

Identifier field


Metadata properties set to true


When you use these values in the same code example, the MinHeight value takes precedence over the MaxHeight value, which in turn takes precedence over the Height value.

When you add or remove rows or columns, the ActualWidth for all ColumnDefinition elements and the ActualHeight of all RowDefinition elements becomes zero until Measure is called.

The following example shows how to create and use an instance of GridLengthConverter. The example defines a custom method called changeCol, which passes the ListBoxItem to a GridLengthConverter that converts the Content of a ListBoxItem to an instance of GridLength. The converted value is then passed back as the value of the Width property of the ColumnDefinition element.

The example also defines a second custom method, called changeColVal. This custom method converts the Value of a Slider to a String and then passes that value back to the ColumnDefinition as the Width of the element.

Note that a separate Extensible Application Markup Language (XAML) file defines the contents of a ListBoxItem.

        private void changeColVal(object sender, RoutedEventArgs e) 
            txt1.Text = "Current Grid Column is " + hs1.Value.ToString();

        private void changeCol(object sender, SelectionChangedEventArgs args)
            ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
            GridLengthConverter myGridLengthConverter = new GridLengthConverter();
            if (hs1.Value == 0)
                GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString());
                col1.Width = gl1;
            else if (hs1.Value == 1)
                GridLength gl2 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString());
                col2.Width = gl2;
            else if (hs1.Value == 2)
                GridLength gl3 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString());
                col3.Width = gl3;

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.