title: How to make TwoWay binding on properties of ObservableCollection of custom class using mvvm pattern?
body: <p>I have the following class:</p>
  
  <pre><code>public class UserGroup
  {
     public string GroupName { get; set; }
     public bool IsIntheGroup{ get; set; }
  }
  </code></pre>
  
  <p>I want to bind an ObservableCollection of UserGroup items to listbox containing checkbox’s for each item in the collection and the checkbox is cheked based on the IsIntheGroup  property of the UserGroup. In my ViewModel I made an ObservableCollection of the UserGroup class:</p>
  
  <pre><code>public ObservableCollection&lt;UserGroup&gt; Groups { get; set; }
  </code></pre>
  
  <p>and loaded its contents (instances of UserGroup) from my database model</p>
  
  <p>I used the following code in my view: </p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding Groups, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"&gt;
     &lt;ListBox.ItemTemplate&gt;
        &lt;DataTemplate&gt;
           &lt;StackPanel Orientation="Horizontal"&gt;
              &lt;CheckBox IsChecked="{Binding IsIntheGroup, Mode=TwoWay}"/&gt;
              &lt;TextBlock Text="{Binding GroupName}" /&gt;
           &lt;/StackPanel&gt;
        &lt;/DataTemplate&gt;
     &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>The problem is I am not notified when the user checks/unchecks a check box in the list so my two way binding failed…</p>
  
  <p>How do I do a two way binding in such a case?</p>