SIGN UP MEMBER LOGIN:    
ARTICLE

UniformGrid in WPF

Posted by Raj Kumar Articles | Learn .NET August 20, 2008
This article show how to use UniformGrid in WPF(Windows Presentation Foundation).
Reader Level:
Download Files:
 

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.

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>

 

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> 

Cool control.

share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor