title: WPF: How can I avoid the flickering of the checked checkboxes in a ListBox or a ListView?
body: <p>How can I avoid the flickering of the checked checkboxes in a WPF ListBox or ListView ? It can be reproduced with the code below by clicking on the Refresh button or by scrolling the listbox. If IsChecked is false, it does not flicker.</p>
  
  <p>Window1.xaml:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication6.Window1"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="Window1" Height="300" Width="300"&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition/&gt;
              &lt;ColumnDefinition/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;ListBox Name="listBox"&gt;
              &lt;ListBox.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackPanel Orientation="Horizontal"&gt;
                          &lt;CheckBox IsChecked="True"
                                    VerticalAlignment="Center"/&gt;
                          &lt;Label Padding="3"
                                 Content="{Binding}"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListBox.ItemTemplate&gt;
          &lt;/ListBox&gt;
          &lt;Button Content="Refresh"
                  Grid.Column="1"
                  VerticalAlignment="Top"
                  Click="Button_Click"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Window1.xaml.cs:</p>
  
  <pre><code>using System.Windows;
  
  namespace WpfApplication6
  {
      partial class Window1 : Window
      {
          public Window1()
          {
              InitializeComponent();
              Button_Click(null, null);
          }
  
          void Button_Click(object sender, RoutedEventArgs e)
          {
              var items = new int[10000];
              for (int i = 0; i &lt; items.Length; i++)
                  items[i] = i + 1;
              listBox.ItemsSource = items;
          }
      }
  }
  </code></pre>