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.

1
  • Show the definition for Grid.Row="0" Commented Oct 17, 2013 at 12:05

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Many thanks! My listview on stackpanel eat 400 ram before.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.