ColumnDefinition ColumnDefinition ColumnDefinition Class

Defines column-specific properties that apply to Grid objects.

Syntax

Declaration

public sealed class ColumnDefinitionpublic sealed class ColumnDefinitionPublic NotInheritable Class ColumnDefinition
<ColumnDefinition .../>

Inheritance Hierarchy

Remarks

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 ColumnSpanProperty 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 summary

Initializes a new instance of the ColumnDefinition class.

Properties summary

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

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

Identifies the MaxWidth dependency property.

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

Identifies the MinWidth dependency property.

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

Identifies the Width dependency property.

Constructors

  • ColumnDefinition()
    ColumnDefinition()
    ColumnDefinition()
    ColumnDefinition()

    Initializes a new instance of the ColumnDefinition class.

    public ColumnDefinition()public New()Public Sub New()public ColumnDefinition()

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 doublepublic double ActualWidth { get; }

    Property Value

    • 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 doublepublic double MaxWidth { get; set; }
    <ColumnDefinition MaxWidth="double"/>
    

    Property Value

  • 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 DependencyPropertypublic static DependencyProperty MaxWidthProperty { get; }

    Property Value

  • 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 doublepublic double MinWidth { get; set; }
    <ColumnDefinition MinWidth="double"/>
    

    Property Value

    • 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 DependencyPropertypublic static DependencyProperty MinWidthProperty { get; }

    Property Value

  • 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 GridLengthpublic GridLength Width { get; set; }
    <ColumnDefinition Width="doubleValue"/>
    - or -
    <ColumnDefinition Width="starSizing"/>
    -or-
    <ColumnDefinition Width="Auto"/>
    

    Property Value

    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.

  • 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 DependencyPropertypublic static DependencyProperty WidthProperty { get; }

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Controls.dll