May 7, 2010 at 2:33 AM
Edited May 7, 2010 at 2:35 PM
I have been stuck here for hours...
I have a wpf DataGrid with a DataGridTemplateColumn. The DataTemplate for the column contains one text box. It has a mulitbinding converter on it, TWO-Way. It all works fine...unless:
1) My ConvertBack method changes the value that the user types in. For example, if the user types in 50 and my ConvertBack changes it to 100, the Convert never gets called. This is because what keeps the converter from being called on the cycle back is that
the PropertyChanged event is ignored if it is raised by the binding source of a two way bind. Great...so the 100 will not be displayed unless I force an "UpdateTarget"
- So if I can get to my control and call: myTextBox.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
HOWEVER, this textbox is in a datatemplate that is in a DataGridTemplateColumn. The GetBindingExpression is always null -- even though the binding is on the Text property. I have read all of the examples that do this for a ListBox...But I have not seen
a single example of how to do this for a datagrid.
How can I force an UpdateTarget on the textbox? <font size="2">
</font>DataGridCell cell =
WPFDataGridHelper.GetCell(pointsDataGrid, 0, 2);
TextBox tb =
// I can see in the debugger that I have the textbox that I want!<font size="2">
</font>BindingExpression be = tb.GetBindingExpression(TextBox.TextProperty);
// The binding expression is always NULL!!!!
I would much appreciate any hints!