开发者

Why do we need to use ConvertBack in IValue Converter

开发者 https://www.devze.com 2023-01-01 15:06 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号