title: how to set checkbox in listbox for specific item in listbox C# WPF
body: <p>I have such a listbox like below:</p>
  
  <pre><code>    &lt;ListBox x:Name="listBox" HorizontalAlignment="Left" Height="385" Margin="21,138,0,0" VerticalAlignment="Top" Width="273" ItemsSource="{Binding Path=locationList}"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;Button Name="btnDelete" Click="btnDelete_Click" Width="15" Height="15" HorizontalAlignment="Center" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Content="x" /&gt;
                      &lt;CheckBox Name="checkBox" /&gt;
                      &lt;TextBlock Name="textBox" Text="{Binding}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  </code></pre>
  
  <p>And what I would like to do is to set checkbox for specific item this listbox.</p>
  
  <p>I am trying to do it: </p>
  
  <pre><code>    private void button4_Click(object sender, RoutedEventArgs e)
      {
          for(int i = 0; i &lt; listBox.Items.Count; i++)
          {
              listBox.Items[i].checkBox = false;
          }
      }
  </code></pre>
  
  <p>I know I am doing an error. I would like to cast it to object of item and then set an item's property (this checkbox) to false. May anyone correct me ? Thank you in advance.</p>
  
  <p><strong>edit</strong>:</p>
  
  <p>Before I was trying to do it this way:</p>
  
  <pre><code>        foreach (var item in listBox.SelectedItems)
          {
              item.
          }
  </code></pre>
  
  <p>but all possibilities I have got are just standard methods: Equals, GetHashCode, GetType, ToString... How I may refer to checkbox ?</p>
  
  <p>Moreover I will supply my question with the insight. I would like to find a specific item by text which is in line in listbox (item) and then change checkbox for this item (same row in listbox).
  Second logic to be implemented is to set all rows to selected or unselected (this is what I am trying to do now).</p>
  
  <p>Thank you for response.</p>