title: Get ListViewItem control in CodeBehind
body: <p>I have a listview and each Item has a CheckBox control as part of its ItemTemplate.</p>
  
  <pre><code>&lt;ListView x:Name="taskListView" Grid.Row="2" BorderThickness="0" Margin="30,0,0,0" ItemsSource="{Binding ChildItems}"&gt;
          &lt;ListView.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="25"/&gt;
                          &lt;ColumnDefinition Width="290"/&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;CheckBox Grid.Column="0" HorizontalAlignment="Center"&gt;&lt;/CheckBox&gt;
                      &lt;TextBlock Text="{Binding Name}" MaxWidth="270" Grid.Column="1" Margin="0,0,10,0"/&gt;
                      &lt;ComboBox SelectedItem="{Binding DependentTask, Mode=TwoWay}" 
                                Grid.Column="2"
                                Margin="0,3,0,3"
                                ItemsSource="{Binding DependentTasks, Converter={StaticResource addEmptyItemConverter}}" 
                                HorizontalAlignment="Left"
                                MinWidth="150"
                                DisplayMemberPath="ProjectionTaskLink.Name"/&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListView.ItemTemplate&gt;
      &lt;/ListView&gt;
  </code></pre>
  
  <p>There is a parent to this ListView that has a checkbox as well. When that parent checkbox is checked, I want to check all the checkboxes in the ListViewItems. How can I get a hold of those in Codebehind so i can set them to Checked or Unchecked depending on the parent condition?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: Here is the full XAML:</p>
  
  <pre><code>&lt;Grid Margin="0,10,0,0"&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="25"/&gt;
          &lt;RowDefinition Height="20"/&gt;
          &lt;RowDefinition Height="*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid Grid.Row="0"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="25"/&gt;
              &lt;ColumnDefinition Width="400"/&gt;
              &lt;ColumnDefinition Width="35"/&gt;
              &lt;ColumnDefinition Width="35"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;CheckBox HorizontalAlignment="Center" Grid.Column="0" Checked="CheckBox_Checked"/&gt;
          &lt;TextBlock Text="{Binding Name}" Grid.Column="1"/&gt;
          &lt;TextBlock Text="Loops " Grid.Column="2" TextAlignment="Center"/&gt;
          &lt;TextBox Text="{Binding Scenarios}" Grid.Column="3"/&gt;
      &lt;/Grid&gt;
      &lt;TextBlock Visibility="{Binding ContainsProjectionTasks, Converter={StaticResource boolToVisibilityConverter}}" 
                     HorizontalAlignment="Left" 
                     Width="450" 
                     TextAlignment="Right" 
                     VerticalAlignment="Bottom" 
                     Grid.Row="1" 
                     Text="Task Dependencies" 
                     Background="White"/&gt;
      &lt;ListView x:Name="taskListView" Grid.Row="2" BorderThickness="0" Margin="30,0,0,0" ItemsSource="{Binding ChildItems}"&gt;
          &lt;ListView.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="25"/&gt;
                          &lt;ColumnDefinition Width="290"/&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;CheckBox Grid.Column="0" HorizontalAlignment="Center"&gt;&lt;/CheckBox&gt;
                      &lt;TextBlock Text="{Binding Name}" MaxWidth="270" Grid.Column="1" Margin="0,0,10,0"/&gt;
                      &lt;ComboBox SelectedItem="{Binding DependentTask, Mode=TwoWay}" 
                                Grid.Column="2"
                                Margin="0,3,0,3"
                                ItemsSource="{Binding DependentTasks, Converter={StaticResource addEmptyItemConverter}}" 
                                HorizontalAlignment="Left"
                                MinWidth="150"
                                DisplayMemberPath="ProjectionTaskLink.Name"/&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListView.ItemTemplate&gt;
      &lt;/ListView&gt;
  &lt;/Grid&gt;
  </code></pre>