Skip to main content
.NET Framework Class Library
FrameworkElementMinHeight Property

Gets or sets the minimum height constraint of the element.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
<[%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_0%](GetType([%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_1%]))> _
<[%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_2%]([%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_3%].None, Readability := [%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_4%].Unreadable)> _
Public Property MinHeight As [%$TOPIC/ms600893_en-us_VS_110_1_0_0_0_5%]
[[%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_0%](typeof([%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_1%]))]
[[%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_2%]([%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_3%].None, Readability = [%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_4%].Unreadable)]
public [%$TOPIC/ms600893_en-us_VS_110_1_0_1_0_5%] MinHeight { get; set; }
[[%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_0%](typeof([%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_1%]))]
[[%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_2%]([%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_3%]::None, Readability = [%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_4%]::Unreadable)]
public:
property [%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_5%] MinHeight {
	[%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_6%] get ();
	void set ([%$TOPIC/ms600893_en-us_VS_110_1_0_2_0_7%] value);
}
[<[%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_0%](typeof([%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_1%]))>]
[<[%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_2%]([%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_3%].None, Readability = [%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_4%].Unreadable)>]
member MinHeight : [%$TOPIC/ms600893_en-us_VS_110_1_0_3_0_5%] with get, set
<object MinHeight="double"/>
- or -
<object MinHeight="qualifiedDouble"/>

XAML Values

double

Double

String representation of a Double value equal to or greater than 0.0. This is interpreted as a device-independent unit (1/96th inch) measurement. Strings need not explicitly include decimal points. For instance a value of 1 is acceptable.

The same Double range restrictions as mentioned in the Property Value section apply.

qualifiedDouble

A double value as described above, followed by one of the following unit declaration strings: 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: SystemDouble
The minimum height of the element, in device-independent units (1/96th inch per unit). The default value is 0.0. This value can be any value equal to or greater than 0.0. However, PositiveInfinity is NOT valid, nor is DoubleNaN.
Dependency Property Information

Identifier field

MinHeightProperty

Metadata properties set to true

AffectsMeasure

Remarks

This is one of three properties on FrameworkElement that specify height information. The other two are Height and MaxHeight. If there is a conflict between these values, the order of application for actual height determination is first MinHeight must be honored, then MaxHeight, and finally if each of these are within bounds, Height.

The value restrictions on the Double value are enforced by a ValidateValueCallback mechanism. If you attempt to set an invalid value, a run-time exception is thrown.

Examples

This example visually shows the differences in rendering behavior among the four height-related properties in Windows Presentation Foundation (WPF).

The FrameworkElement class exposes four properties that describe the height characteristics of an element. These four properties can conflict, and when they do, the value that takes precedence is determined as follows: the MinHeight value takes precedence over the MaxHeight value, which in turn takes precedence over the Height value. A fourth property, ActualHeight, is read-only, and reports the actual height as determined by interactions with the layout process.

The following Extensible Application Markup Language (XAML) examples draw a Rectangle element (rect1) as a child of Canvas. You can change the height properties of a Rectangle by using a series of  ListBox elements that represent the property values of MinHeight, MaxHeight, and Height. In this manner, the precedence of each property is visually displayed.

<Canvas Height="200" MinWidth="200" Background="#b0c4de" VerticalAlignment="Top"  HorizontalAlignment="Center" Name="myCanvas" Margin="0,0,0,50">
    <Rectangle HorizontalAlignment="Center" Canvas.Top="50" Canvas.Left="50"  Name="rect1" Fill="#4682b4" Height="100" Width="100"/>
</Canvas>


...


    <TextBlock Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle Height:</TextBlock>
    <ListBox Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem>
    </ListBox>

	<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MinHeight:</TextBlock>
    <ListBox Grid.Column="3" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeMinHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem>
  </ListBox>      

    <TextBlock Grid.Row="1" Grid.Column="4" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MaxHeight:</TextBlock>
    <ListBox Grid.Column="5" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeMaxHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem> 
    </ListBox>

The following code-behind examples handle the events that the SelectionChanged event raises. Each handler takes the input from the ListBox, parses the value as a Double, and applies the value to the specified height-related property. The height values are also converted to a string and written to various TextBlock elements (definition of those elements is not shown in the selected XAML).

Private Sub changeHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)
    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.Height = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub 
Private Sub changeMinHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)

    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.MinHeight = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub 
Private Sub changeMaxHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)

    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.MaxHeight = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub
private void changeHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.Height = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMinHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MinHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMaxHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MaxHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}

For the complete sample, see Height Properties Sample.

Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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