Skip to content

Commit dd00e87

Browse files
authored
Merge pull request #1 from PlonkaAdam/uwp-fix-scroll-performance
UWP - Fix DataGrid scroll performance issues
2 parents 77b009d + 30cb970 commit dd00e87

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridDataConnection.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,11 @@ public int Count
123123
return list.Count;
124124
}
125125

126-
#if FEATURE_PAGEDCOLLECTIONVIEW
127-
PagedCollectionView collectionView = this.DataSource as PagedCollectionView;
126+
var collectionView = this.DataSource as ICollectionView;
128127
if (collectionView != null)
129128
{
130129
return collectionView.Count;
131130
}
132-
#endif
133131

134132
int count = 0;
135133
IEnumerable enumerable = this.DataSource;
@@ -498,13 +496,11 @@ public object GetDataItem(int index)
498496
return (index < list.Count) ? list[index] : null;
499497
}
500498

501-
#if FEATURE_PAGEDCOLLECTIONVIEW
502-
PagedCollectionView collectionView = this.DataSource as PagedCollectionView;
499+
var collectionView = this.DataSource as ICollectionView;
503500
if (collectionView != null)
504501
{
505-
return (index < collectionView.Count) ? collectionView.GetItemAt(index) : null;
502+
return (index < collectionView.Count) ? collectionView[index] : null;
506503
}
507-
#endif
508504

509505
IEnumerable enumerable = this.DataSource;
510506
if (enumerable != null)
@@ -579,13 +575,11 @@ public int IndexOf(object dataItem)
579575
return list.IndexOf(dataItem);
580576
}
581577

582-
#if FEATURE_PAGEDCOLLECTIONVIEW
583-
PagedCollectionView cv = this.DataSource as PagedCollectionView;
584-
if (cv != null)
578+
var collectionView = this.DataSource as ICollectionView;
579+
if (collectionView != null)
585580
{
586-
return cv.IndexOf(dataItem);
581+
return collectionView.IndexOf(dataItem);
587582
}
588-
#endif
589583

590584
IEnumerable enumerable = this.DataSource;
591585
if (enumerable != null && dataItem != null)

0 commit comments

Comments
 (0)