LongListSelector Windows Phone 8.1

I wanted to Develop a similar layout like Lonlist Selector Wp8 in Windows phone 8.1.

I came across a issue, My list is not appearing.

XAML page

    <Grid.Resources>
        <CollectionViewSource x:Name="MainGrps"
                      IsSourceGrouped="True"/>
    </Grid.Resources>

    <ListView ItemsSource="{Binding Source={StaticResource MainGrps}}"  Margin="50">

         <ListView.ItemTemplate>
            <DataTemplate >
                <Grid Background="Gray">
                    <StackPanel>
                        <TextBlock Foreground="White" FontSize="20" Text="{Binding ItmName}"/>
                        <TextBlock Foreground="White" FontSize="20" Text="{Binding ItmType}"/>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>

        <ListView.GroupStyle>
            <GroupStyle HidesIfEmpty="True" >
                <GroupStyle.HeaderTemplate>
                    <DataTemplate >
                        <Grid Background="Red">
                            <StackPanel Orientation="Horizontal" >
                                <TextBlock Text="{Binding GrpItmName}" Foreground="White"/>
                                <TextBlock Text="{Binding ItemsCount}" Foreground="White"/>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListView.GroupStyle>
    </ListView>
</Grid>

Code Behind

private void OnPageLoaded(object sender, RoutedEventArgs e)
{
lst_grp = new List();

        for (int i = 0; i < 10; i++)
        {
            Grp grp = new Grp();
            grp.GrpItmName = "grp name " + i;
            grp.ItemsCount = i;

            grp.LstItms = new List<Itm>();

            Itm itm = new Itm();
            itm.ItmName = "itm name " + i;
            itm.ItmType = "itm type " + i;

            grp.LstItms.Add(itm);
            grp.LstItms.Add(itm);
            grp.LstItms.Add(itm);

            lst_grp.Add(grp);
        }

        this.MainGrps.Source = lst_grp;
    }

Any problem with above code?

Please help me to figure it out or suggest if u have working one


Source: windows

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.