Blog

Windows 8 Grid View control metro UI app

Posted by Parin Turakhia Blogs | Windows Store Apps May 07, 2012
Windows 8 Grid View control metro UI app
Hi Guys,
Following will help you to create Grid View control in Windows 8 metro UI apps XAML.

Step 1:

 Create User Control resources and the following 
   <CollectionViewSource x:Name="cvsItemSource" IsSourceGrouped="True"/>
 

Step 2:

  <GridView  x:Name="grdView"  BorderThickness="0" VerticalAlignment="Stretch"
                                           ItemsSource="{Binding Source={StaticResource cvsItemSource}}" 
                                             >
                                        <GridView.ItemTemplate>
                                            <DataTemplate x:Name="MainPage">
                                                         Here Is the template you want to display. 
                                            </DataTemplate>

                                        </GridView.ItemTemplate>

                                        <GridView.GroupStyle>
                                            <GroupStyle>
                                                <GroupStyle.Panel>
                                                    <ItemsPanelTemplate>
                                                        <VariableSizedWrapGrid Orientation="Vertical" MaximumRowsOrColumns="2" Margin="0,0,0,0"/>
                                                    </ItemsPanelTemplate>
                                                </GroupStyle.Panel>
                                                <GroupStyle.HeaderTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Margin="0,0,0,0"  Text="Title of the group" FontSize="25" Height="33" Foreground="#ffe1c4" />
                                                    </DataTemplate>
                                                </GroupStyle.HeaderTemplate>


                                            </GroupStyle>
                                        </GridView.GroupStyle>
                                        <GridView.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <StackPanel Orientation="Horizontal" />
                                            </ItemsPanelTemplate>
                                        </GridView.ItemsPanel>

                                    </GridView>
Step 3:

Assign your item collection to the Item Source as follows:

cvsItemSource.Source = Your Collections;

comments
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts