Why do we need to use ConvertBack in IValue Converter
I am not sure Why we need to use I 开发者_高级运维ConvertBack
method in IValueConverter
.
In the Convert
method itself we do the conversion and return the updated value to be bound in our control.
So in which Scenario we should use Convertback. I know this question is very basic but just wanted to make the fundamentals clear.
Thanks a lot for your help and suggestions.
Thanks, Subhen
I don't use it often, but it's my understanding it's for when a binding updates the source value. Wherever your binding updates the source (on the view model usually), and specifies a converter, it will use ConvertBack.
So to give a fabricated example; if your converter added a currency symbol to the start of a double, when a user changed that value your converter would want to remove the symbol again before trying to set the double value on your VM.
精彩评论