Data Binding and updating the current control

Nov 3, 2009 at 7:30 PM

I have a textbox with a multivalue converter on it that gets fired on the lost focus event. It functions perfectly in that all of the data fields are properly updated and their property notifications fire. Other controls bound to the data object (in the case below, the Name field) correctly display the results of the converter. The problem is, the control that fired the lost_focus seems to ignore the PropertyChanged event when the convertback changes the data object. Any other control bound to the same data object responds and correctly displays the update.

This seems pretty easy to replicate. Take a multivalue converter and use it on a textbox. In the debugger, set a break point in the ConvertBack method. Change the value that is bound to the text box so that it gets written out to the data object. (For example, if the user entered 123, change it to 456). Watch as the Convert method executes. You'll see the new value in it...But the textbox control's content is not updated.  Any other control accessing that data object is updated.

I have read that this is a known issue in WPF but the articles say that it is fixed if you use the lost focus event. That is not what I am seeing. Any workarounds?

                            <MultiBinding Converter="{StaticResource FixNameToHistoryDataTypeConverter}" 
                                    <Binding Path="Name" ValidatesOnDataErrors="True" NotifyOnValidationError="True"/>
                                    <Binding Path="HistoryDataType" ValidatesOnDataErrors="True" NotifyOnValidationError="True"/>
                                    <Binding Path="Amount" />
                                    <Binding Path="Loss" />
                                    <Binding Path="Current" />
                                    <Binding Path="Hint" />
FixNameToHistoryDataTypeConverter - if it modifies the Name field, this control will not listen to the PropertyChanged event. Any other controls bound
to these fields will visually update.