DataGridTemplateColumn Two way binding is not working DataGridTemplateColumn Two way binding is not working wpf wpf

DataGridTemplateColumn Two way binding is not working


I had the same problem, not updating the source:

<DataGridTemplateColumn Header="Obs" IsReadOnly="False">  <DataGridTemplateColumn.CellTemplate>     <DataTemplate>         <TextBox Name="txtObs" Width="80"                  Text="{Binding Path=ObsPedido, Mode=TwoWay}"/>      </DataTemplate>  </DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>

For me it worked just adding UpdateSourceTrigger=PropertyChanged

<TextBox Name="txtObs" Width="80"         Text="{Binding Path=ObsPedido, Mode=TwoWay,         UpdateSourceTrigger=PropertyChanged}"/>


I had the same problem and the solution posted by @jrivam did not help. For me to get my binding to work correctly I had to change the CellEditingTemplate to use the OneWayToSource Binding Mode.

<DataGridTemplateColumn.CellEditingTemplate>    <DataTemplate>        <TextBox Text="{Binding Path=IC_DEF_CHAR_TEXT,                 Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"/>    </DataTemplate></DataGridTemplateColumn.CellEditingTemplate>