Placing elements in uniform cells
Just like the Grid
layout system in Windows Presentation Foundation, the UniformGrid
control also provides the similar layout system, but only with a difference that the rows and columns are of same size. It equally divides the layout into cells, of the same size, based on the number of rows and columns. Thus, you will not have the choice to modify the height and width of the rows and columns explicitly.
In this recipe, we will learn about the UniformGrid
layout with a simple example.
Getting ready
Let's create a sample application to demonstrate the UniformGrid
control. Open your Visual Studio IDE and create a new WPF application project named CH03.UniformGridDemo
.
How to do it...
Now perform the following steps:
- From
Solution Explorer
, open theMainWindow.xaml
page. - Replace the existing
Grid
panel with the following XAML code:
<UniformGrid> <Label Content="Cell 1" Background="Yellow" /> <Label Content="Cell 2" Background="YellowGreen"...