title: How can I handle this cast exception in C# : system.data.model in system.windows.controls.CheckBox?
body: <p>This is my model class of analys</p>
  <pre><code>public partial class analys
      {
          public int id { get; set; }
          public string name { get; set; }
          public int price { get; set; }
          public bool Type_qualitatif { get; set; }
          public bool Type_quantitatif { get; set; }
          public System.DateTime create_at { get; set; }
          public System.DateTime update_at { get; set; }
          public int sectionId { get; set; }
      
          public virtual section section { get; set; }
      }
  }
  </code></pre>
  <p>I create a ListBox which display checkboxes as items, and the content of each one is the name of an analys.</p>
  <p>So I am trying to get the content of the checkboxes checked and save them in a list with the code bellow</p>
  <pre><code>foreach ( CheckBox item in  _biochimieExam.BiochimieExamsItemsControl.Items )
               {
                   if(item.IsChecked == true)
                   {
                     //  String exam = item.Content.ToString();
                       SelctedItems.Add(item.Content.ToString());
                   }
               } 
              
              foreach(String item in SelctedItems)
              {
                  BchExamsList.Add(new analys
                  {
                      name = item
                  }) ;
              }
  
  </code></pre>
  <p>But I'm getting an inavlid cast exception <strong>Impossible to cast an object of type 'System.Data.Entity.DynamicProxies.analys_F69488E20B133B223573E1D5931B83214F85574493596933EB8BFDBD5F513C59' in type 'System.Windows.Controls.CheckBox'.'</strong> which I try to resolve. But a I failed.</p>
  <p>Please I need some help. Thanks.</p>