title: Slow performance of list view in WPF
body: <p>I have a list view with a ton of data and any time I go to scroll / click somewhere on the screen it always takes a few seconds to react. I tried setting the list view to use virtualization but can't seem to get it to work.</p>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/296533/wpf-listview-very-slow-performance-why-elementhost-or-other-reason">this</a> and <a href="https://stackoverflow.com/questions/570918/wpf-listview-gridview-performance-horrible-suggestions">this</a>. Not sure if I am doing something wrong or not understanding how the virtualization works? </p>
  
  <p>I do have a lot of styling / added grid view behaviors for my listview. If you have any suggestions please let me know! </p>
  
  <p><strong>What I Have Tried</strong></p>
  
  <ul>
  <li>I have tried removing the CollapseableCollumnBehavior from the list view. Had no change.</li>
  <li>Removed all my font styles. Had no change.</li>
  <li>Reduced the number of columns. Had a small change but still very unresponsive.</li>
  <li>Turned off IsSyncronizedWithCurrentItem. Had no change.</li>
  </ul>
  
  <p><strong>Item Source</strong></p>
  
  <p>My item source is just an observable collection.This is how I load data into it.</p>
  
  <pre><code>private void LoadAllData()
  {
      using (var uow = _unitOfWorkFactory.Create())
      {
          foreach (var rule in _ruleRepository.GetAllRulesInCheckProcess())
          {
              AllRulesInCheckProcess.Add(rule);
          }
      }
  }
  </code></pre>
  
  <p><strong>XAML:</strong></p>
  
  <p>I took out a lot of my styling and added column behaviors from the xaml to simplify the code.</p>
  
  <pre><code>&lt;ListView SelectedValue="{Binding SelectedRule}" 
        IsSynchronizedWithCurrentItem="True"
        Grid.Column="0"
        MinHeight="150"
        VirtualizingStackPanel.IsVirtualizing="True"
        VirtualizingStackPanel.VirtualizationMode="Recycling"
        ScrollViewer.IsDeferredScrollingEnabled="True"
        ItemsSource="{Binding AllRulesInCheckProcess}"
        MaxHeight="300"
        ScrollViewer.HorizontalScrollBarVisibility="Visible"&gt;
  &lt;ListView.View&gt;
      &lt;GridView&gt;
          &lt;GridViewColumn  DisplayMemberBinding="{Binding Description}" Width="auto"&gt;
              &lt;GridViewColumnHeader Content="Description"&gt;
                  &lt;GridViewColumnHeader.ContentTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel&gt;
                              &lt;TextBox Height="25" 
                                       FontSize="{StaticResource FontSizeSmall}" 
                                       Text="{Binding ElementName=RulesInCheckProgressPage, Path=DataContext.DescriptionFilter}"
                                       Tag="Filter Description"/&gt;
                              &lt;TextBlock Text="Description"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumnHeader.ContentTemplate&gt;
              &lt;/GridViewColumnHeader&gt;
          &lt;/GridViewColumn&gt;
          &lt;GridViewColumn DisplayMemberBinding="{Binding LaunchDate,StringFormat=MM/dd/yy}" 
                          Width="auto"&gt;
              &lt;GridViewColumnHeader Content="Launch Date"&gt;
                  &lt;GridViewColumnHeader.ContentTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel&gt;
                              &lt;TextBox Height="25" 
                                       FontSize="{StaticResource FontSizeSmall}" 
                                       Tag="Filter Launch Date"
                                       Text="{Binding ElementName=RulesInCheckProgressPage, Path=DataContext.LaunchDateFilter}"/&gt;
                              &lt;TextBlock Text="Launch Date"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumnHeader.ContentTemplate&gt;
              &lt;/GridViewColumnHeader&gt;
  
          &lt;/GridViewColumn&gt;
          &lt;GridViewColumn DisplayMemberBinding="{Binding AddedDate,StringFormat=MM/dd/yy}" Width="auto"&gt;
              &lt;GridViewColumnHeader Content="Added Date"&gt;
                  &lt;GridViewColumnHeader.ContentTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel&gt;
                              &lt;TextBox Height="25" 
                                       FontSize="{StaticResource FontSizeSmall}" Tag="Filter Added Date"
                                       Text="{Binding ElementName=RulesInCheckProgressPage, Path=DataContext.AddedDateFilter}"/&gt;
                              &lt;TextBlock Text="Added Date"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumnHeader.ContentTemplate&gt;
              &lt;/GridViewColumnHeader&gt;
          &lt;/GridViewColumn&gt;
      &lt;/GridView&gt;
  &lt;/ListView.View&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So through doing some more research it appears I may need to take a look at data virtualization instead of UI virtualization. Does anyone know of any up to date data virtualization code?</p>