Radu Olteanu
Radu Olteanu

Reputation: 443

How to Add Grouping and Incremental Loading Support for a GridView in UWP

Currently I'm able to perform grouping using a CollectionViewSource instance that is being binded to a GridView ItemSource. All is working as aspected but I need to add Incremental Loading Support, and I managed to do this in other context using IncrementalLoadingCollection, but I'm not sure if this can be done together without making any UI tweaks.

Currently my code is looking like this :

<GridView
                    x:Name="test"
                          Margin="18,20,0,0"
                          Grid.Row="3"
                          Loaded="All_GridView_Loaded"
                          SelectionMode="Single"
                          ScrollViewer.VerticalScrollBarVisibility="Hidden"
                          HorizontalAlignment="Stretch">
                    <GridView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate x:DataType="someType">
                                    <TextBlock Text="{Binding Key}"/>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </GridView.GroupStyle>
                    <GridView.ItemTemplate>
                        <DataTemplate x:DataType="someType" x:DefaultBindMode="OneWay">


                           .........
                  </DataTemplate>
                    </GridView.ItemTemplate>
                </GridView>

And the code behind for binding :

 var cvs = new CollectionViewSource { IsSourceGrouped = true };
     cvs.Source = some list ....;

     gridView.ItemsSource = cvs.View;

Upvotes: 0

Views: 181

Answers (1)

user11639555
user11639555

Reputation:

Try use MVVM Helpers library by James Montemagno, it has Grouping and ObservableRangeCollection of which you asked for. To see a quick demo watch his video. Or browse on Project github

Upvotes: 1

Related Questions