ColumnDefinition 类

定义

定义应用于 Grid 对象的列特定属性。

public ref class ColumnDefinition sealed : DependencyObject
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ColumnDefinition final : DependencyObject
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class ColumnDefinition final : DependencyObject
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ColumnDefinition : DependencyObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class ColumnDefinition : DependencyObject
Public NotInheritable Class ColumnDefinition
Inherits DependencyObject
<ColumnDefinition .../>
继承
Object Platform::Object IInspectable DependencyObject ColumnDefinition
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例使用三个 ColumnDefinition 和三个 RowDefinition创建一个包含九个单元格的网格,例如工作表中的单元格。 每个单元格包含一个代表数据的 TextBlock 元素,而最上面的一行包含应用了 ColumnSpan 属性的 TextBlock

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

构造函数

ColumnDefinition()

初始化 ColumnDefinition 类的新实例。

属性

ActualWidth

获取一个值,该值表示 ColumnDefinition 的实际计算宽度。

Dispatcher

获取与此 对象关联的 CoreDispatcherCoreDispatcher 表示可以访问 UI 线程上的 DependencyObject 的工具,即使代码是由非 UI 线程启动的。

(继承自 DependencyObject)
MaxWidth

获取或设置一个值,该值表示 ColumnDefinition 的最大宽度。

MaxWidthProperty

标识 MaxWidth 依赖属性。

MinWidth

获取或设置一个值,该值表示 ColumnDefinition 的最小宽度。

MinWidthProperty

标识 MinWidth 依赖属性。

Width

获取 ColumnDefinition 元素的计算宽度,或设置 ColumnDefinition 定义的列的 GridLength 值。

WidthProperty

标识 Width 依赖属性。

方法

ClearValue(DependencyProperty)

清除依赖属性的本地值。

(继承自 DependencyObject)
GetAnimationBaseValue(DependencyProperty)

返回为依赖属性建立的任何基值,该基值适用于动画未处于活动状态的情况。

(继承自 DependencyObject)
GetValue(DependencyProperty)

DependencyObject 返回依赖属性的当前有效值。

(继承自 DependencyObject)
ReadLocalValue(DependencyProperty)

如果设置了本地值,则返回依赖属性的本地值。

(继承自 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

注册一个通知函数,用于侦听此 DependencyObject 实例上特定 DependencyProperty 的更改。

(继承自 DependencyObject)
SetValue(DependencyProperty, Object)

设置 DependencyObject 上依赖属性的本地值。

(继承自 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消以前通过调用 RegisterPropertyChangedCallback 注册的更改通知。

(继承自 DependencyObject)

适用于

另请参阅