Share via


ColumnDefinition.Width 屬性

定義

取得 ColumnDefinition 專案的計算寬度,或設定 ColumnDefinition 所定義之數據行的 GridLength 值。 這是 ColumnDefinition 的內容屬性

public:
 property GridLength Width { GridLength get(); void set(GridLength value); };
GridLength Width();

void Width(GridLength value);
public GridLength Width { get; set; }
var gridLength = columnDefinition.width;
columnDefinition.width = gridLength;
Public Property Width As GridLength
<ColumnDefinition Width="doubleValue"/>
- or -
<ColumnDefinition Width="starSizing"/>
-or-
<ColumnDefinition Width="Auto"/>

屬性值

GridLength,代表數據行的寬度。 默認值為 GridLength ,代表 「1*」 重設大小。

備註

Width 的預設值是 GridLength ,代表 「1*」 重設大小。 這個結構值具有值為 1.0 的 Value 數據值,以及 StarGridUnitType 數據值。 使用這個預設值時,您為 Grid 定義的每個新 ColumnDefinition 都會有 “1*” 大小調整,而且每個都會在配置處理中配置內容寬度的像素數相等。 將 ColumnDefinition 定義為 XAML 中的物件項目並沒有任何屬性設定,而且只使用此預設行為並不常見。 RowDefinition 也是如此。

如果您同時為 MinWidthMaxWidth 設定值,則可以限制您為 Width 設定的值。 每一個屬性只能測量圖元,而不是 形重設大小。 如果 ColumnDefinition 使用 StarAuto 重設大小,但也有 MinWidthMaxWidth 條件約束,則 MinWidthMaxWidth 必須接受 Grid 版面配置行為,即使這表示提供或取自方格中未具有條件約束之其他形重設大小數據行的版面配置空間也一樣。

使用 C++、C# 或 Visual Basic 在 UWP 應用程式中使用網格線定義的形重設大小比絕對圖元值更常見。 形重設大小支援動態版面配置概念,可協助您的應用程式在具有不同大小、圖元密度和方向的螢幕上看起來很棒。 如需詳細資訊,請參閱 使用 XAML 定義版面配置。

適用於

另請參閱