--- title: "How to: Set the Height Properties of an Element" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "height properties [WPF]" - "Panel control [WPF], height properties of elements" ms.assetid: 5ab9e781-dbb8-469a-a3c8-cf38ce312647 --- # How to: Set the Height Properties of an Element ## Example This example visually shows the differences in rendering behavior among the four height-related properties in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)]. The 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 value takes precedence over the value, which in turn takes precedence over the value. A fourth property, , is read-only, and reports the actual height as determined by interactions with the layout process. The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] examples draw a element (`rect1`) as a child of . You can change the height properties of a by using a series of elements that represent the property values of , , and . In this manner, the precedence of each property is visually displayed. [!code-xaml[HeightMinHeightMaxHeight#1](~/samples/snippets/csharp/VS_Snippets_Wpf/HeightMinHeightMaxHeight/CSharp/Window1.xaml#1)] [!code-xaml[HeightMinHeightMaxHeight#2](~/samples/snippets/csharp/VS_Snippets_Wpf/HeightMinHeightMaxHeight/CSharp/Window1.xaml#2)] The following code-behind examples handle the events that the event raises. Each handler takes the input from the , parses the value as a , and applies the value to the specified height-related property. The height values are also converted to a string and written to various elements (definition of those elements is not shown in the selected XAML). [!code-csharp[HeightMinHeightMaxHeight#3](~/samples/snippets/csharp/VS_Snippets_Wpf/HeightMinHeightMaxHeight/CSharp/Window1.xaml.cs#3)] [!code-vb[HeightMinHeightMaxHeight#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/HeightMinHeightMaxHeight/VisualBasic/Window1.xaml.vb#3)] For the complete sample, see [Height Properties Sample](https://github.com/microsoft/WPF-Samples/tree/master/Elements/HeightProperties). ## See also - - - - - - - [Set the Width Properties of an Element](how-to-set-the-width-properties-of-an-element.md) - [Panels Overview](panels-overview.md) - [Height Properties Sample](https://github.com/microsoft/WPF-Samples/tree/master/Elements/HeightProperties)