title: C# How to check all checkboxes on listview
body: <p>How to check all checkboxes on listview? </p>
  
  <p>Listview xaml:</p>
  
  <pre><code>&lt;ListView x:Name="List" HorizontalAlignment="Left" Height="559" Margin="10,10,0,0" VerticalAlignment="Top" Width="607" Grid.ColumnSpan="2" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Auto" IsMouseCapturedChanged="List_IsMouseCapturedChanged"&gt;
          &lt;ListView.ContextMenu&gt;
              &lt;ContextMenu&gt;
                  &lt;MenuItem Name="Dodaj" Header="Dodaj" Click="DodajUtwor_Click"/&gt;
                  &lt;MenuItem Name="Usuń" Header="Usuń Zaznaczone" Click="UsuńUtwór_Click"/&gt;
                  &lt;MenuItem Name="Clear" Header="Wyczyść Listę" Click="ClearList_Click"/&gt;
                  &lt;MenuItem Name="Check" Header="Zaznacz Wszystkie" Click="SelectAll_Click"/&gt;
              &lt;/ContextMenu&gt;
          &lt;/ListView.ContextMenu&gt;            
          &lt;ListView.View&gt;
              &lt;GridView&gt;
                  &lt;GridViewColumn Width="30" &gt;
                      &lt;GridViewColumn.CellTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;StackPanel Orientation="Horizontal"&gt;
                                  &lt;CheckBox Name="CheckBox" Padding="10" IsChecked="{Binding IsChecked}"/&gt;                           
                                  &lt;TextBlock Text="{Binding Data}"/&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/GridViewColumn.CellTemplate&gt;
                  &lt;/GridViewColumn&gt;
                  &lt;GridViewColumn Header="Nazwa Pliku" Width="100" DisplayMemberBinding="{Binding Nazwa}" /&gt;
                  &lt;GridViewColumn Header="Tytuł" Width="100" DisplayMemberBinding="{Binding Tytuł}"/&gt;
                  &lt;GridViewColumn Header="Wykonawca" Width="100" DisplayMemberBinding="{Binding Autor}"/&gt;
                  &lt;GridViewColumn Header="Album" Width="100" DisplayMemberBinding="{Binding Album}"/&gt;
                  &lt;GridViewColumn Header="Nr" Width="100" DisplayMemberBinding="{Binding Nr}"/&gt;
                  &lt;GridViewColumn Header="Rok" Width="100" DisplayMemberBinding="{Binding Rok}"/&gt;
                  &lt;GridViewColumn Header="Gatunek" Width="100" DisplayMemberBinding="{Binding Gatunek}"/&gt;
                  &lt;GridViewColumn Header="Komantarze" Width="100" DisplayMemberBinding="{Binding Komentarze}"/&gt;
                  &lt;GridViewColumn Header="Okładka" Width="100" DisplayMemberBinding="{Binding Okładka}"/&gt;
                  &lt;GridViewColumn Header="Lokalizacja" Width="100" DisplayMemberBinding="{Binding Lokalizacja}"/&gt;
              &lt;/GridView&gt;
          &lt;/ListView.View&gt;
  
      &lt;/ListView&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
          {
              MyItem selectedItem = (MyItem)this.List.SelectedItem;
              selectedItem.IsChedked = true;
              List.Items.Refresh();
  
  
          }
  </code></pre>
  
  <p>Don't work.
  I want to change all checkboxes on true in a listviev. I dont know how to use loop foreach. And how to delete items witch checkboxes on true? </p>