This article is currently in the process of being translated into Dutch (~29% done).


Het Grid - Rijen & Kolommen

In het vorige hoofdstuk hebben we je kennis laten maken met het geweldige Grid paneel en hebben we je in een paar basisvoorbeelden laten zien hoe je het kunt gebruiken. In dit hoofdstuk gaan we wat meer geavanceerdere lay-outs maken, want dit is waar het Grid echt in uitblinkt. Laten we om te beginnen meer kolommen en zelfs wat rijen toevoegen, voor een echte tabelvormige lay-out:

<Window x:Class="WpfTutorialSamples.Panels.TabularGrid"
        Title="TabularGrid" Height="300" Width="300">
			<ColumnDefinition Width="2*" />
			<ColumnDefinition Width="1*" />
			<ColumnDefinition Width="1*" />
			<RowDefinition Height="2*" />
			<RowDefinition Height="1*" />
			<RowDefinition Height="1*" />
		<Button>Button 1</Button>
		<Button Grid.Column="1">Button 2</Button>
		<Button Grid.Column="2">Button 3</Button>
		<Button Grid.Row="1">Button 4</Button>
		<Button Grid.Column="1" Grid.Row="1">Button 5</Button>
		<Button Grid.Column="2" Grid.Row="1">Button 6</Button>
		<Button Grid.Row="2">Button 7</Button>
		<Button Grid.Column="1" Grid.Row="2">Button 8</Button>
		<Button Grid.Column="2" Grid.Row="2">Button 9</Button>

A total of nine buttons, each placed in their own cell in a grid containing three rows and three columns. We once again use a star based width, but this time we assign a number as well - the first row and the first column has a width of 2*, which basically means that it uses twice the amount of space as the rows and columns with a width of 1* (or just * - that's the same).

You will also notice that I use the Attached properties Grid.Row and Grid.Column to place the controls in the grid, and once again you will notice that I have omitted these properties on the controls where I want to use either the first row or the first column (or both). This is essentially the same as specifying a zero. This saves a bit of typing, but you might prefer to assign them anyway for a better overview - that's totally up to you!

This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!