ColumnDefinition.Width 屬性

定義

取得ColumnDefinition專案的計算寬度,或設定ColumnDefinition所定義之資料行的GridLength值。

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 定義版面配置。

適用於

另請參閱