【问题标题】:How to Add Grouping and Incremental Loading Support for a GridView in UWP如何在 UWP 中为 GridView 添加分组和增量加载支持
【发布时间】:2019-11-04 11:53:19
【问题描述】:

目前,我可以使用绑定到 GridView ItemSource 的 CollectionViewSource 实例执行分组。一切都按方面工作,但我需要添加增量加载支持,我设法在其他情况下使用 IncrementalLoadingCollection 做到这一点,但我不确定这是否可以在不进行任何 UI 调整的情况下一起完成.

目前我的代码是这样的:

<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>

以及绑定的代码:

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

     gridView.ItemsSource = cvs.View;

【问题讨论】:

  • 为什么这个有uwp以外的标签? Incrementalloadingcollection 不是 uwp 独有的吗?
  • @Andy 也许还有其他方法可以做到这一点,是的,incrementalloadingcollection 是特定于 uwp 的,但它对我来说不是强制性的,我只是想找出一个解决方案

标签: wpf xamarin xamarin.forms uwp


【解决方案1】:

尝试使用 James Montemagno 的 MVVM Helpers 库,它有您要求的 GroupingObservableRangeCollection。观看快速演示观看his video。 或浏览Project github

【讨论】:

    猜你喜欢
    • 2018-04-08
    • 2017-06-18
    • 2015-11-16
    • 1970-01-01
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    相关资源
    最近更新 更多