![]() Each row has an explicit height of 50 device-independent units.In this example, sizing works as follows: The following XAML shows how to create a Grid with two rows and two columns: To make elements span across multiple rows and columns, use the Grid.RowSpan and Grid.ColumnSpan attached properties.Ī Grid layout should not be confused with tables, and is not intended to present tabular data. To position elements in specific Grid cells, use the Grid.Column and Grid.Row attached properties. A grid's rows and columns are specified with the RowDefinitions and ColumnDefinitions properties. GridĪ Grid is used for displaying elements in rows and columns, which can have proportional or absolute sizes. In a VerticalStackLayout, if an element's size is not explicitly set, it expands to fill the available width.įor more information, see VerticalStackLayout. The following XAML shows how to create a VerticalStackLayout containing three Label objects: VerticalStackLayout is typically used to arrange a subsection of the UI on a page. VerticalStackLayoutĪ VerticalStackLayout organizes child views in a one-dimensional vertical stack, and is a more performant alternative to a StackLayout. In a HorizontalStackLayout, if an element's size is not explicitly set, it expands to fill the available height.įor more information, see HorizontalStackLayout. The following XAML shows how to create a HorizontalStackLayout containing different child views: HorizontalStackLayout is typically used to arrange a subsection of the UI on a page. HorizontalStackLayoutĪ HorizontalStackLayout organizes child views in a one-dimensional horizontal stack, and is a more performant alternative to a StackLayout. Instead, the desired layout can be better achieved by using a Grid.įor more information, see StackLayout. This is wasteful because unnecessary layout calculations are performed. The following code shows an example of this bad practice: However, a StackLayout should not be used to reproduce a Grid layout by using a combination of StackLayout objects. In a StackLayout, if an element's size is not explicitly set, it expands to fill the available width, or height if the Orientation property is set to Horizontal.Ī StackLayout is often used as a parent layout, which contains other child layouts. The following XAML shows how to create a vertical StackLayout containing three Label objects: StackLayout is typically used to arrange a subsection of the UI on a page. The Orientation property specifies the direction of the elements, and the default orientation is Vertical. StackLayoutĪ StackLayout organizes elements in a one-dimensional stack, either horizontally or vertically. ![]() In addition, it may be necessary to nest layouts to create your desired layout. Choosing a layout class requires knowledge of how the layout positions its child elements, and how the layout sizes its child elements. ![]() NET Multi-platform App UI (.NET MAUI) layout classes allow you to arrange and group UI controls in your application.
0 Comments
Leave a Reply. |