When does ConvertBack method get called?

Nawaz picture Nawaz · Mar 23, 2011 · Viewed 9.6k times · Source

I know that when data is about to be displayed, Convert() method is called to convert the data and the converted data is displayed instead.

I'm wondering when ConvertBack() method gets called? What is its purpose?

I've a DataGrid whose ItemSource is binded to some collection, and I've implemented IValueConverter for one property of items in the collection. When I make IsReadOnly="True" (in the DataGrid), then ConvertBack method is called if I double-click on the cell (for which IValueConverter is implemented) and then change the focus. But when I make IsReadOnly="False", then ConvertBack method is never called, no matter what I do with the DataGrid and its cells.

Please explain this behavior of DataGrid cells and ConvertBack method of IValueConverter.

Answer

blindmeis picture blindmeis · Mar 23, 2011

"The data binding engine calls this method when it propagates a value from the binding target to the binding source."

see msdn

you should post your binding for your cell with the valueconverter