tags:

views:

350

answers:

4

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

+1  A: 

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

ArsenMkrt
A: 

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:

  • Try pre-loading/caching your data if possible.
  • Double check that the property getters for MIACODE and MIANAME aren't performing CPU instensive work, and aren't creating any side effects.
  • Use Linq to page the in-bound data.

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.

Mark
A: 

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.

Mark
A: 

Thank you so much!!