Maurizio Reginelli
Maurizio Reginelli

Reputation: 3212

ValueConverter with data binding

Is it possible to add a dependency property to a ValueConverter and bind it to a property of the object to which the converter is applied?

Upvotes: 0

Views: 163

Answers (1)

Bryan Anderson
Bryan Anderson

Reputation: 16129

It isn't possible to do this in XAML. What you'd usually want to use for the sort of problem I'm guessing you have is a IMultiValueConverter.

If you really had to you could wire it up like you suggest in the code behind for your view but I really wouldn't recommend it. First it is much more difficult to manage and second your property won't be updated when the value you've bound to the new dependency property changes (i.e. the Convert method won't be called again). You're much better off using an IMultiValueConverter.

Upvotes: 1

Related Questions