Export (0) Print
Expand All
Expand Minimize

GridUnitType Enumeration

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

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

type GridUnitType
<object property="enumerationMemberName" .../>

Member nameDescription
AutoThe size is determined by the size properties of the content object.
PixelThe value is expressed as a pixel.
StarThe value is expressed as a weighted proportion of available space.

Star sizing is used to distribute available space by weighted proportions.

In Extensible Application Markup Language (XAML), star values are expressed as * or 2*. In the first case, the row or column would receive one times the available space; in the second case, the row or column would receive two times the available space, and so on.

This example shows how to create a standard user interface (UI) dialog box by using the Grid element.

The following example creates a dialog box like the Run dialog box in the Windows operating system.

The example creates a Grid and uses the ColumnDefinition and RowDefinition classes to define five columns and four rows.

The example then adds and positions an Image, RunIcon.png, to represent the image that is found in the dialog box. The image is placed in the first column and row of the Grid (the upper-left corner).

Next, the example adds a TextBlock element to the first column, which spans the remaining columns of the first row. It adds another TextBlock element to the second row in the first column, to represent the Open text box. A TextBlock follows, which represents the data entry area.

Finally, the example adds three Button elements to the final row, which represent the OK, Cancel, and Browse events.

No code example is currently available or this language may not be supported.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      WindowTitle="Grid Run Dialog Sample" 
      WindowWidth="425" 
      WindowHeight="225">
  <Grid Background="#DCDCDC"
        Width="425"
        Height="165"
        HorizontalAlignment="Left"
        VerticalAlignment="Top"
        ShowGridLines="True">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Image Grid.Column="0" Grid.Row="0" Source="RunIcon.png" />
    <TextBlock Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="0" TextWrapping="Wrap">
      Type the name of a program, folder, document, or
      Internet resource, and Windows will open it for you.
    </TextBlock>
    <TextBlock Grid.Column="0" Grid.Row="1">Open:</TextBlock>
    <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" />
    <Button Margin="10, 0, 10, 15" Grid.Row="3" Grid.Column="2">OK</Button>
    <Button Margin="10, 0, 10, 15" Grid.Row="3" Grid.Column="3">Cancel</Button>
    <Button Margin="10, 0, 10, 15" Grid.Row="3" Grid.Column="4">Browse ...</Button>
  </Grid>
</Page>

.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

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.

Show:
© 2014 Microsoft