GridUnitType GridUnitType GridUnitType GridUnitType Enum


Describes the kind of value that a GridLength object is holding.

public : enum class GridUnitType
enum class winrt::Windows::UI::Xaml::GridUnitType : int32_t
public enum GridUnitType
Public Enum GridUnitType
<object property="enumMemberName"/>

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


Auto Auto Auto Auto 0

The size is determined by the size properties of the content object.

Pixel Pixel Pixel Pixel 1

The value is expressed in pixels.

Star Star Star Star 2

The value is expressed as a weighted proportion of available space.


This example shows how to position some TextBlock objects and a Rectangle inside a Grid.

<Grid >
        <Style TargetType="TextBlock">
            <Setter Property="FontSize" Value="36"/>

        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*"/>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    <TextBlock Margin="2" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3"
        This TextBlock is positioned in the first column and the 
        first row (column 0, row 0) and spans across all three columns (ColumnSpan 3).
    <TextBlock Grid.Column="0" Grid.Row="1" Margin="5" FontWeight="Bold">Rectangle:</TextBlock>
    <Rectangle Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" Fill="Red"
   Width="200" Height="50"/>
    <Button Grid.Column="0" Grid.Row="2" Content="Stretched Button" />
    <Border Background="Blue"  BorderThickness="5" Grid.Row="2" Grid.Column="1" Grid.RowSpan="2" >
        <TextBlock TextWrapping="Wrap">
           This TextBlock spans across two rows.
    <TextBlock Margin="5" Grid.Row="3" Grid.Column="0">1st Column, 4th Row</TextBlock>
    <TextBlock Margin="5" Grid.Row="3" Grid.Column="2">3rd Column, 4th Row</TextBlock>

See also