DataGridTemplateColumn Two way binding is not working

妖精的绣舞 提交于 2019-12-03 00:41:12
jrivam

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!