Grouping Grid View Items with Semantic Zoom and existing code RRS feed

  • Question

  • I'm trying to find the quickest and most efficient way to implement some GridView Items for my Windows 8.1 app.

    Below is my XAML:

        DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
            <CollectionViewSource x:Name="viewSource" IsSourceGrouped="True"/>
            This grid acts as a root panel for the page that defines two rows:
            * Row 0 contains the back button and page title
            * Row 1 contains the rest of the page layout
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
                <RowDefinition Height="140"/>
                <RowDefinition Height="*"/>
            <!-- Back button and page title -->
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="*"/>
                <Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                            Style="{StaticResource NavigationBackButtonNormalStyle}"
                            AutomationProperties.ItemType="Navigation Button"/>
                <TextBlock x:Name="pageTitle" Text="Victoria line" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                            IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40" Foreground="#FF0099CC"/>
            <GridView x:Name="Victoria_line" Grid.Row="1" Margin="20,0,0,0">
                <SemanticZoom x:Name="semanticZoom">
                        <GridView x:Name="wideView">
                                    <WrapGrid ItemWidth="150" ItemHeight="150" MaximumRowsOrColumns="1" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding Path=GroupTitle}" FontSize="56"/>
                        <GridView x:Name="detailView" ItemsSource="{Binding Source={StaticResource viewSource}}">
                                    <StackPanel Orientation="Horizontal"/>
                                <GroupStyle HidesIfEmpty="True">
                                            <TextBlock Text="{Binding Path=Key.GroupTitle}" FontSize="26"/>
                                            <VariableSizedWrapGrid Orientation="Vertical"/>
                                    <StackPanel Width="450" Tapped="VictoriaItem_Tap">
                                        <TextBlock Text="{Binding Title}" FontSize="32"/>
                                        <TextBlock Text="{Binding Zone}" FontSize="20"/>

    The code below is what I used for my WP8.x app. I know the same thing can't be reused for Windows 8.1 but I'm unsure what I would need to change for the sake of Windows 8.1

        Public Sub New()
            Dim source As New List(Of Victoria)()
            source.Add(New Victoria("Blackhorse Road", "Fare zone 3", "/Lines and Stations/Victoria/BHO_(Victoria).xaml"))
            source.Add(New Victoria("Seven Sisters", "Fare zone 3", "/Lines and Stations/Victoria/SVS_(Victoria).xaml"))
            Dim DataSource As List(Of AlphaKeyGroup(Of Victoria)) = AlphaKeyGroup(Of Victoria).CreateGroups(source, System.Threading.Thread.CurrentThread.CurrentUICulture, Function(s As Victoria)
                                                                                                                                                                                Return s.Station
                                                                                                                                                                            End Function, True)
            VictoriaLine.ItemsSource = DataSource
        End Sub

    The code below I have also included in my project, but I'm unsure if the code is correct for the items to appear.

        Public Class Victoria
            Public Property Station() As String
                    Return m_Station
                End Get
                Set(value As String)
                    m_Station = value
                End Set
            End Property
            Private m_Station As String
            Public Property FareZone() As String
                    Return m_FareZone
                End Get
                Set(value As String)
                    m_FareZone = value
                End Set
            End Property
            Private m_FareZone As String
            Public Property Link() As String
                    Return m_Link
                End Get
                Set(value As String)
                    m_Link = value
                End Set
            End Property
            Private m_Link As String
            Public Sub New(station As String, farezone As String, link As String)
                Me.Station = station
                Me.FareZone = farezone
                Me.Link = link
            End Sub
        End Class

    This is what I'm trying to achieve.

    Friday, May 23, 2014 1:05 PM


  • Hi,

    There are different ways that you can group data coming into your app. The data source might be a list of items where each item also contains a list of items. For example, you could display a list of projects, where each project has a property that is a list of activities. Or you might use a LINQ query that returns  grouped items. You can refer to the link to get more information about How to group items in a list or grid .

    And refer to the XAML GridView grouping and SemanticZoom sample

    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Anne Jing Friday, May 30, 2014 7:46 AM
    Monday, May 26, 2014 1:28 AM