2

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:

  • Very slow (a couple of minutes) to do the initial bind
  • Very slow (over a minute) scrolling
  • Very slow (again, well over a minute) when you select a row.

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>

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.

Tobias
  • 232
  • 1
  • 16
GrayDS
  • 363
  • 1
  • 6
  • 18

1 Answers1

6

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

Gray

GrayDS
  • 363
  • 1
  • 6
  • 18
  • Many thanks! My listview on stackpanel eat 400 ram before. –  Aug 17 '16 at 15:48
  • After trying so many other things out this finally solved my problem. But I fail to understand why. I read somewhere that virtualization can only work when a maximum height of a control is set. But Microsofft's official documentation doesn't say anthing about this or the reason for it. It's puzzling that something so important gets mentioned nowhere save for your answer here. – Simon Voggeneder Jan 16 '19 at 08:01