title: how to databind textbox inside WPF datagrid to a property in viewmodel?
body: <p>How to bind textbox inside WPF Data grid to a property in view model? I am using MVVM pattern.</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding Channels}" AutoGenerateColumns="False" ColumnWidth="*" CanUserAddRows="False"&gt;
              &lt;DataGrid.Columns&gt;
  
                  &lt;DataGridTemplateColumn Header="Display Name"&gt;
                      &lt;DataGridTemplateColumn.CellTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;TextBox Text="{Binding DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="200"/&gt;                        
  &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellTemplate&gt;
                  &lt;/DataGridTemplateColumn&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>DisplayName is a property as defined below:</p>
  
  <pre><code>private string displayName;
          public string DisplayName
          {
              get { return displayName; }
              set
              {
                  if (displayName != value)
                  {                    displayName = value;
                      RaisePropertyChanged(() =&gt; DisplayName);
                  }
              }
          }
  </code></pre>