Add the Grid as the Content of the Parent Window Object Add the TextBlock elements to the Grid Children collection Txt8.Text = 'Total Units: ' + (db1 + db2 + db3).ToString()
RowDefinition rowDef4 = new RowDefinition() RowDefinition rowDef3 = new RowDefinition() RowDefinition rowDef2 = new RowDefinition() RowDefinition rowDef1 = new RowDefinition() MyGrid.VerticalAlignment = VerticalAlignment.Top ĬolumnDefinition colDef1 = new ColumnDefinition() ĬolumnDefinition colDef2 = new ColumnDefinition() ĬolumnDefinition colDef3 = new ColumnDefinition() MyGrid.HorizontalAlignment = HorizontalAlignment.Left In this case, the grid defines three ColumnDefinition elements and four RowDefinition elements that host child content. The following example demonstrates how to create a grid.