title: Loop Through TabItem CheckBoxes
body: <p>I have a group of 50 <code>CheckBoxes</code> that are placed inside a <code>TabItem</code>. On a button click, I need to loop through the <code>CheckBoxes</code> and based upon whether the <code>CheckBox.Ischecked</code> is <code>true</code> or <code>false</code>, it's relevant variable will be set to a 0 or a 1. </p>
  
  <p>Here is some code I've begun with to try and get a start;</p>
  
  <pre><code>private void ApplyPrivilegeUpdateClick(object sender, RoutedEventArgs e)
  {
      var newPrivilegeModel = new EmployeePrivilegeModel();
      int i = 0;
      foreach (CheckBox c in companiesTabItem)
      {
          if (c.IsChecked == true)
          {
              newPrivilegeModel.Priv1 = 1;
          }
          i++;
      }
  }
  </code></pre>
  
  <p><code>newPrivlegeModel.Priv1</code> - This goes up to <code>Priv50</code>, so <code>Priv1, Priv2, Priv3</code> etc etc. What I really don't want to have to do is do an <code>If</code> loop for all 50 <code>CheckBoxes</code> and set their relevant <code>Priv</code>. </p>
  
  <p>I have two problems, how do I loop through all the 50 <code>CheckBoxes</code> in the <code>TabItem</code>? And how can I code the <code>newPrivlegeModel.Priv1</code> so that they are all automatically updated? For example, <code>newPrivlegeModel.Priv + i</code> does not work so how do I get round this?</p>