Notice that for the third Border we use an extra attribute, Grid.ColumnSpan, which causes this Border to span both columns in the lower row. Add the following code to the Grid element after the row and column definitions. The values of these attributes default to 0, so you don't need to assign them to the first Border. Each is also assigned to a row and column in the parent Grid by using the Grid.Row and Grid.Column attributes. To color the Grid we add three Border elements, each with a different background color. To show the Grid let's give it some color. If you run the application now you won't see anything except a blank page, because none of the Grid areas have any content. To learn about other methods of sizing rows and columns, see Define layouts with XAML. These ratios are maintained even if the window is resized or the device is changed. In the same way, the two rows have a Height of "2*" and "*" respectively, so the Grid allocates two times as much space for the first row as for the second ("*" is the same as "1*"). The first column has a Width of "3*", while the second has "5*", dividing the horizontal space between the two columns at a ratio of 3:5. The new Grid creates a set of two rows and columns, which defines the layout of the app interface. To start creating a layout, open MainPage.xaml by using the Solution Explorer, and replace the automatically generated Grid element with this code. Rows and columns are defined with the RowDefinition and ColumnDefinition elements. By specifying the row and column of an element within a Grid, you can place and space other elements within a user interface. In XAML a Grid is made up of a series of rows and columns.
0 Comments
Leave a Reply. |