UniformGrid WPF in VB.NET

This article show how to use UniformGrid in WPF(Windows Presentation Foundation).
  • 2370

UniformGrid has a namespace System.Windows.Controls.Primitives.Good thing is in UniformGrid is it displays child elements in columns and rows of the same size. The order of the elements is given by it is order they have been added.   

Here is a simple example a UniformGrid has two rows and two columns with four Image controls.

  <UniformGrid Columns="2" Rows="2" Name="uniformGrid1" >

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

  </UniformGrid> 

 

Result looks like this.

 

Image1.jpg
 

If I add one more Image control then you will see that image at design time but it will not be visible at run-time.

<UniformGrid Columns="2" Rows="2" Name="uniformGrid1" >

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

        </UniformGrid>

 Image2.jpg
 

 

If you want to display all five images, you will have to add one more row to the grid, like this :

<UniformGrid Columns="2" Rows="3" Name="uniformGrid1" >

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

            <Image Source="ais176v.jpg"></Image>

        </UniformGrid> 

 

Image3.jpg
 

Cool control.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.