GridViewColumn.Width 属性

定义

获取或设置列的宽度。Gets or sets the width of the column.

public:
 property double Width { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
public double Width { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))>]
member this.Width : double with get, set
Public Property Width As Double

属性值

Double

该列的宽度。The width of the column. 默认值为 NaN,可自动根据非列标题的最大列项调整大小。The default is NaN, which automatically sizes to the largest column item that is not the column header.

属性

示例

下面的示例演示如何设置 Width 属性。The following example shows how to set the Width property.

GridViewColumn gvc1 = new GridViewColumn();
gvc1.DisplayMemberBinding = new Binding("FirstName");
gvc1.Header = "FirstName";
gvc1.Width = 100;
Dim gvc1 As New GridViewColumn()
gvc1.DisplayMemberBinding = New Binding("FirstName")
gvc1.Header = "FirstName"
gvc1.Width = 100
<GridViewColumn DisplayMemberBinding=
                    "{Binding Path=FirstName}" 
                Header="First Name" Width="100"/>

注解

若要在此属性设置为时获取精确宽度 Double.NaN ,请使用 ActualWidth 属性。To get the exact width when this property is set to Double.NaN, use the ActualWidth property.

XAML 属性用法XAML Attribute Usage

<object Width="double"/>  
- or -  
<object Width="qualifiedDouble"/>  
- or -  
<object Width="Auto"/>  

XAML 值XAML Values

doubledouble
Double

值的字符串表示形式 DoubleString representation of a Double value. 这会被解释为 与设备无关的单位(1/96 英寸)device-independent unit (1/96th inch) 度量值。This is interpreted as a 与设备无关的单位(1/96 英寸)device-independent unit (1/96th inch) measurement. 字符串不需要显式包含小数点。Strings need not explicitly include decimal points. 例如,的值 1 是可接受的。For instance a value of 1 is acceptable.

qualifiedDoublequalifiedDouble
如上所述的 双精度 值,后跟以下单元声明字符串之一: pxincmptA double value as described above, followed by one of the following unit declaration strings: px, in, cm, pt.

px (默认) 为 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)px (default) is 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)

in 为英寸;1in = = 96pxin is inches; 1in==96px

cm 为厘米;1cm = = (96/2.54) pxcm is centimeters; 1cm==(96/2.54) px

pt 为点;1pt = = (96/72) pxpt is points; 1pt==(96/72) px

Auto
启用自动调整行为。Enables autosizing behavior. 请参阅“备注”。See Remarks.

依赖项属性信息Dependency Property Information

标识符字段Identifier field WidthProperty
元数据属性设置为 trueMetadata properties set to true AffectsMeasure

适用于

另请参阅