xaml code
<ListView Name="lvw" VirtualizingStackPanel.IsVirtualizing="True" ItemsSource="{Binding Source={StaticResource MyList}}" >
<ListView.View>
<GridView AllowsColumnReorder="true" VirtualizingStackPanel.IsVirtualizing="True" >
<GridViewColumn x:Name="MiaCode" DisplayMemberBinding="{Binding Path=MIACODE}" Header="code" Width="80" />
<GridViewColumn x:Name="MiaName" DisplayMemberBinding="{Binding Path=MIANAME}" Header="name" Width="270"/>
</GridView>
</ListView.View>
</ListView>
//Binding Data count is over 10000
even though I set the property [VirtualizingStackPanel.IsVirtualizing="True"]
,
it takes too long to display data.
is there anything wrong in my code??
Upvotes: 0
Views: 1743
Reputation: 9428
Oh... just spotted that you're binding to a static resource....
If you are creating an explicit CollectionViewSource resource for grouping and sorting your items, take care to note that the by-property sorting mechanism of the CollectionView is known to be slow.
If this scenario describes what you're doing, try using a customer sort filter with the collection view (which is considerably faster), or better yet retrieve your data pre-sorted the way it needs to be.
Broadly speaking, you can only rely on the based sorting of CollectionView up to a few thousand items before the sorting time shows it's poorer performance.
Upvotes: 0
Reputation: 9428
Confirming the correctness of arsenmkrt's reply.
A virtualized items source is generally pretty fast as long as it's not waiting for the underlying data to load.
If you get no joy, here are some more considerations:
From experience, though, I can confirm that the GridView on a virtualized listview is amply capable of displaying thousands of items without severe performance panalties. Hope this helps you.
Upvotes: 0
Reputation: 50712
Is MyList a static data? you can use asynchronous binding by setting IsAsync property Binding.IsAsync Property or asynchronous data loading see ObjectDataProvider.IsAsynchronous Property,or develop some paging mechanism
VirtualizingStackPanel.IsVirtualizing = "true" is not speeding up data loading time, it just doesn't create UI elements that are not visible
Hope this helps
Upvotes: 1