Column​Definition Column​Definition Column​Definition Column​Definition Class

Definition

Defines column-specific properties that apply to Grid objects.

public : sealed class ColumnDefinition : DependencyObject, IColumnDefinitionpublic sealed class ColumnDefinition : DependencyObject, IColumnDefinitionPublic NotInheritable Class ColumnDefinition Inherits DependencyObject Implements IColumnDefinition// This API is not available in Javascript.
<ColumnDefinition .../>
Inheritance
ColumnDefinitionColumnDefinitionColumnDefinitionColumnDefinition
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited methods

Inherited properties

Examples

The following example uses three ColumnDefinition s and three RowDefinition s to create a grid that has nine cells, such as in a worksheet. Each cell contains a TextBlock element that represents data, and the top row contains a TextBlock with the ColumnSpan property applied.

<Grid  VerticalAlignment="Top" HorizontalAlignment="Left"
       Width="350" Height="200">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>

    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               FontSize="20" FontWeight="Bold" 
               Grid.ColumnSpan="3" Grid.Row="0">Expenses for 2007</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               FontSize="15" FontWeight="Bold" 
               Grid.Row="1" Grid.Column="0">Travel</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               FontSize="15" FontWeight="Bold" 
               Grid.Row="1" Grid.Column="1">Office Supplies</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
               FontSize="15" FontWeight="Bold" 
               Grid.Row="1" Grid.Column="2">Salary</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               Grid.Row="2" Grid.Column="0">20000</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               Grid.Row="2" Grid.Column="1">10000</TextBlock>
    
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
               Grid.Row="2" Grid.Column="2">50000</TextBlock>

    <TextBlock FontSize="16" FontWeight="Bold" 
               Grid.ColumnSpan="3" Grid.Row="3">Total Expense: 80000</TextBlock>
</Grid>

Constructors

ColumnDefinition() ColumnDefinition() ColumnDefinition() ColumnDefinition()

Initializes a new instance of the ColumnDefinition class.

public : ColumnDefinition()public ColumnDefinition()Public Sub New()// This API is not available in Javascript.

Properties

ActualWidth ActualWidth ActualWidth ActualWidth

Gets a value that represents the actual calculated width of a ColumnDefinition.

public : double ActualWidth { get; }public double ActualWidth { get; }Public ReadOnly Property ActualWidth As double// This API is not available in Javascript.
Value
double double double double

A Double that represents the actual calculated width in pixels. The default is 0.

MaxWidth MaxWidth MaxWidth MaxWidth

Gets or sets a value that represents the maximum width of a ColumnDefinition.

public : double MaxWidth { get; set; }public double MaxWidth { get; set; }Public ReadWrite Property MaxWidth As double// This API is not available in Javascript.
<ColumnDefinition MaxWidth="double"/>
Value
double double double double

A Double that represents the maximum width in pixels. The default is PositiveInfinity.

MaxWidthProperty MaxWidthProperty MaxWidthProperty MaxWidthProperty

Identifies the MaxWidth dependency property.

public : static DependencyProperty MaxWidthProperty { get; }public static DependencyProperty MaxWidthProperty { get; }Public Static ReadOnly Property MaxWidthProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier for the MaxWidth dependency property.

MinWidth MinWidth MinWidth MinWidth

Gets or sets a value that represents the minimum width of a ColumnDefinition.

public : double MinWidth { get; set; }public double MinWidth { get; set; }Public ReadWrite Property MinWidth As double// This API is not available in Javascript.
<ColumnDefinition MinWidth="double"/>
Value
double double double double

A Double that represents the minimum width in pixels. The default is 0.

MinWidthProperty MinWidthProperty MinWidthProperty MinWidthProperty

Identifies the MinWidth dependency property.

public : static DependencyProperty MinWidthProperty { get; }public static DependencyProperty MinWidthProperty { get; }Public Static ReadOnly Property MinWidthProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier for the MinWidth dependency property.

Width Width Width Width

Gets the calculated width of a ColumnDefinition element, or sets the GridLength value of a column that is defined by the ColumnDefinition.

public : GridLength Width { get; set; }public GridLength Width { get; set; }Public ReadWrite Property Width As GridLength// This API is not available in Javascript.
<ColumnDefinition Width="doubleValue"/>
- or -
<ColumnDefinition Width="starSizing"/>
-or-
<ColumnDefinition Width="Auto"/>
Value
GridLength GridLength GridLength GridLength

The GridLength that represents the width of the column. 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 ColumnDefinition you define for a Grid will have "1*" sizing, and each will be allotted an equal number of pixels for width of its content in layout handling. It's not uncommon to define ColumnDefinition as an object element in XAML without any attributes set and to just use this default behavior. The same is true for RowDefinition.

The value you set for Width can be constrained if you also set a value for MinWidth or MaxWidth. Each of these properties can take only pixel measurements, not Star sizing. If a ColumnDefinition uses Star or Auto sizing but also has MinWidth or MaxWidth constraints, the MinWidth or MaxWidth must be honored by the Grid layout behavior, even if that means giving or taking layout space from other Star sizing columns 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 Windows Store 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.

See Also

WidthProperty WidthProperty WidthProperty WidthProperty

Identifies the Width dependency property.

public : static DependencyProperty WidthProperty { get; }public static DependencyProperty WidthProperty { get; }Public Static ReadOnly Property WidthProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier for the Width dependency property.

See Also