File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
MPowerKit.VirtualizeListView Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public class GroupableDataAdapter(VirtualizeListView listView) : DataAdapter(lis
77{
88 public class GroupItem ( IEnumerable group , object data ) : AdapterItem ( data )
99 {
10- public object Group { get ; set ; } = group ;
10+ public IEnumerable Group { get ; set ; } = group ;
1111 }
1212 public class GroupHeaderItem ( IEnumerable group ) : GroupItem ( group , group ) { }
1313 public class GroupFooterItem ( IEnumerable group ) : GroupItem ( group , group ) { }
@@ -345,6 +345,8 @@ protected override void OnCollectionChangedReset(IEnumerable? itemsSource)
345345 return ;
346346 }
347347
348+ ResetGroups ( InternalItems . OfType < GroupItem > ( ) . DistinctBy ( i => i . Group ) . Select ( i => i . Group ) ) ;
349+
348350 if ( itemsSource is not IEnumerable < IEnumerable > groups )
349351 {
350352 throw new ArgumentException ( "The collection type for IsGrouped should be only typeof(IEnumerable<IEnumerable>) or derived interfaces or classes from it" ) ;
Original file line number Diff line number Diff line change 2020
2121 <GeneratePackageOnBuild >True</GeneratePackageOnBuild >
2222 <Title >MPowerKit.VirtualizeListView</Title >
23- <Version >2.0.1 </Version >
23+ <Version >2.0.2 </Version >
2424 <Authors >MPowerKit,Alex Dobrynin</Authors >
2525 <Description >MAUI Virtualize ListView with smooth scrolling and without platform-specific code</Description >
2626 <Copyright >MPowerKit</Copyright >
Original file line number Diff line number Diff line change 3030 Padding =" 15"
3131 Grid.Row=" 2"
3232 BackgroundColor =" Aqua"
33- IsGrouped =" False " >
33+ IsGrouped =" True " >
3434 <mpowerkit : VirtualizeListView .Resources>
3535 <ResourceDictionary >
3636 <Style TargetType =" mpowerkit:LinearItemsLayoutManager" >
4747 VerticalItemSpacing="15" />-->
4848 </mpowerkit : VirtualizeListView .ItemsLayout>
4949
50- <!-- < mpowerkit:VirtualizeListView.GroupHeaderTemplate>
50+ <mpowerkit : VirtualizeListView .GroupHeaderTemplate>
5151 <DataTemplate x : DataType =" local:ItemsGroup" >
5252 <Grid Padding =" 15"
5353 BackgroundColor =" Aqua" >
5454 <Label Text =" {Binding Key}"
5555 TextColor =" Black" />
5656 </Grid >
5757 </DataTemplate >
58- </mpowerkit:VirtualizeListView.GroupHeaderTemplate>-->
58+ </mpowerkit : VirtualizeListView .GroupHeaderTemplate>
5959 <mpowerkit : VirtualizeListView .ItemTemplate>
6060 <local : ItemTemplateSelector >
6161 <local : ItemTemplateSelector .EvenTemplate>
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ public MainPage()
5454
5555 private void FillItems ( )
5656 {
57+ ( listView . ItemsSource as ObservableRangeCollection < ItemsGroup > ) ? . Clear ( ) ;
58+
5759 var items = new ObservableRangeCollection < Item > ( ) ;
5860
5961 for ( int i = 0 ; i < 500 ; i ++ )
@@ -68,7 +70,7 @@ private void FillItems()
6870 } ) ;
6971 }
7072
71- listView . ItemsSource = items ; // .GroupBy(i => (int)(i.Id / 10.0)).Select(g => new ItemsGroup(g, g.Key));
73+ listView . ItemsSource = new ObservableRangeCollection < ItemsGroup > ( items . GroupBy ( i => ( int ) ( i . Id / 10.0 ) ) . Select ( g => new ItemsGroup ( g , g . Key ) ) ) ;
7274 }
7375
7476 private async void FixedRefreshView_Refreshing ( object sender , EventArgs e )
You can’t perform that action at this time.
0 commit comments