WPF ListView的大数据非常差的性能 [英] WPF ListView very poor performance with large data
问题描述
我遇到了在WPF一个ListView,使用30000左右表现的记录非常差。据我所知,虚拟化应打开,因为这是默认的(我甚至在XAML打开它明确)。
I am experiencing very poor performance with a ListView in WPF, using around 30000 records. As far as I know Virtualisation should be turned on as this is the default (I even turned it on explicitly in the XAML).
表现不佳以这种方式体现:
The poor performance manifests in this way:
- 很慢(一两分钟)做初始绑定
- 很慢(超过一分钟)滚动
- 很慢(再次,超过一分钟),当你选择行。
我希望有人能来看看在XAML,让我有一些想法。
I was hoping someone would take a look at the XAML and let me have some thoughts.
<ListView Name="grdComms" Grid.Row="0" Grid.Column="0" SelectedItem="{Binding SelectedHeader}"
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True">
<ListView.View>
<GridView >
<GridViewColumn Header="Account Name" DisplayMemberBinding="{Binding Path=AccountName}" Width="150" />
<GridViewColumn Header="Account Number" DisplayMemberBinding="{Binding Path=AccountNumber}" Width="120" />
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding Path=Type}" Width="80" />
<GridViewColumn Header="Delivery" DisplayMemberBinding="{Binding Path=Delivery}" Width="80" />
<GridViewColumn Header="Count" DisplayMemberBinding="{Binding Path=RequestCount}" Width="80" />
<GridViewColumn Width="80" Header="DeDupe">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Width="80">
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=SelectedForProcessing, Mode=TwoWay}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
注:的ItemsSource设置在code,到一个ObservableCollection。这是pretty普通属性的集合(几个字符串,一个布尔值),这是一个视图模型到模型,这是(再次)字符串和布尔变量。
Note: the ItemsSource is set in code, to an ObservableCollection. This is a collection of pretty plain properties (couple of strings, a bool), which is a ViewModel onto the Model, which is (again) strings and bools.
我看那里的人都使用大的记录集,没有任何问题,但我似乎已经试过各种事情不工作。
I'm reading where people are using large record sets with no problems, but the various things I have tried don't seem to work.
任何请告诉我需要更多的信息。
Any more information required please let me know.
推荐答案
请不理我了。只要我设置的ListView的东西大于它所需要的了maxHeight的问题完全消失。我发誓瞎我尝试这样做,显然不是。
Please ignore me. The problem entirely disappears as soon as I set the MaxHeight of the ListView to something bigger than it needs. I would swear blind I tried this, obviously not.
待着,没有什么可看这里......
Move along, there is nothing to see here ...
灰色
这篇关于WPF ListView的大数据非常差的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!