Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 3.54 KB

columndefinition_width.md

File metadata and controls

45 lines (32 loc) · 3.54 KB
-api-id -api-type
P:Windows.UI.Xaml.Controls.ColumnDefinition.Width
winrt property

Windows.UI.Xaml.Controls.ColumnDefinition.Width

-description

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

-xaml-syntax

<ColumnDefinition Width="doubleValue"/>
- or -
<ColumnDefinition Width="starSizing"/>
-or-
<ColumnDefinition Width="Auto"/>

-xaml-values

doubleValue
doubleValueThe column's width, expressed as a floating-point value for a pixel count. Typically this is specified as an integer, although interpolation of floating-point values is supported by grid layout.
starSizing
starSizingA convention by which you can size rows or columns to take the remaining available space in a Grid. A star sizing always includes the asterisk character (\*), and optionally precedes the asterisk with an integer value that specifies a weighted factor versus other possible star sizings (for example, 3\*). For more information about star sizing, see Grid.
Auto
AutoThe column's width, described by the literal Auto. For more information about Auto sizing, see Grid or GridLength.
## -property-value The [GridLength](../windows.ui.xaml/gridlength.md) that represents the width of the column. The default value is a [GridLength](../windows.ui.xaml/gridlength.md) representing a "1\*" sizing.

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

-examples

-see-also

Grid, Grid.ColumnDefinitions, Grid.Column, Define layouts with XAML