title: How can I bind an ObservableCollection to TextBoxes in a DataTemplate?
body: <p>I am trying to successfully TwoWay bind an ObservableCollection to TextBoxes in a DataTemplate. I can get the data to display properly, but I am unable to change the list data through the UI. I have a Model class named 'model' which contains an ObservableCollection named 'List'. The class implements the INotifyPropertyChanged interface. Here is the xaml for the shell. The DataContext for Window1's grid is set to "theGrid.DataContext=model" </p>
  
  <pre><code>&lt;Window x:Class="BindThat.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:BindThat"
  Title="Window1" Height="300" Width="300"&gt;
  &lt;StackPanel x:Name="theGrid"&gt;
      &lt;GroupBox BorderBrush="LightGreen"&gt;
          &lt;GroupBox.Header&gt;
              &lt;TextBlock Text="Group" /&gt;
          &lt;/GroupBox.Header&gt;
          &lt;ItemsControl ItemsSource="{Binding Path=List}"&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBox Text="{Binding Path=., Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
      &lt;/GroupBox&gt; 
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the code for the Model class:</p>
  
  <pre><code>class Model : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      private void NotifyPropertyChanged(string name)
      {
          if (PropertyChanged != null)
              PropertyChanged(this, new PropertyChangedEventArgs(name));
      }
  
      private ObservableCollection&lt;string&gt; _list = new ObservableCollection&lt;string&gt;();
      public ObservableCollection&lt;string&gt; List
      {
          get { return _list; }
          set 
          { 
              _list = value;
              NotifyPropertyChanged("List");
          }
      }
  
      public Model()
      {
          List.Add("why");
          List.Add("not");
          List.Add("these?");
      }
  }
  </code></pre>
  
  <p>Could anyone advise if I am going about this the correct way?</p>