Sdílet prostřednictvím


RowDefinition.Height Property

Definition

Gets the calculated height of a RowDefinition element, or sets the GridLength value of a row that is defined by the RowDefinition.

public:
 property GridLength Height { GridLength get(); void set(GridLength value); };
GridLength Height();

void Height(GridLength value);
public GridLength Height { get; set; }
var gridLength = rowDefinition.height;
rowDefinition.height = gridLength;
Public Property Height As GridLength
<RowDefinition Height="doubleValue"/>
- or -
<RowDefinition Height="starSizing"/>
-or-
<RowDefinition Height="Auto"/>

Property Value

The GridLength that represents the height of the row. The default value is a GridLength representing a "1*" sizing.

Remarks

The default value of Width is a GridLength representing a "1*" sizing. This structure value has a Value data value of 1.0, and a GridUnitType data value of Star. With this default, each new RowDefinition you define for a Grid will have "1*" sizing, and each will be allotted an equal number of pixels for height of its content in layout handling. It's not uncommon to define RowDefinition as an object element in XAML without any attributes set and to just use this default behavior. The same is true for ColumnDefinition.

The value you set for Height can be constrained if you also set a value for MinHeight or MaxHeight. Each of these properties can take only pixel measurements, not Star sizing. If a RowDefinition uses Star or Auto sizing but also has MinHeight or MaxHeight constraints, the MinHeight or MaxHeight must be honored by the Grid layout behavior, even if that means giving or taking layout space from other Star sizing rows defined in the Grid that don't have constraints.

It's more common to use Star sizing than absolute pixel values for a Grid definition in a UWP app using C++, C#, or Visual Basic. Star sizing supports the dynamic layout concept, which helps your app look great on screens with different sizes, pixel densities and orientations. For more info, see Define layouts with XAML.

Applies to

See also