I have come across the situation where I need to do some Binding for ConverterParameter. Something like
I have done lots of research, and I found out that its impossible to do binding for ConverterParameter.
So I came up with the Solution. I created the Converter but inherited from FrameworkElement
public class ShowDeleteServiceConverter : FrameworkElement, IValueConverter
In the converter class, I created a dependency property
Now, I can do the Binding as usual
And
It might not be the best solution, but it works for me so far. If you have any idea, feel free to drop me comments.
Cheers,
10 comments:
You're a star. I been struggling with this for half a day now. Finally an example that could be applied to a real life scenario.
Nice, you successfully moved the meatball!
This is awesome. Note that you can also use DependencyObject as a base class, which is a lower lever class than FrameworkElement.
How did you make it work ? On my tests the Convert method is being called first, before the binding to the property has passed. This way the property I try to use inside the Convert method is always NULL.
I don't know if it's elegant, but it's pretty smart
Brilliant!!
It's fitted like a glove!
Thank you very much!!!
You're welcome. Glad you liked it
Great idea - just doesn't work for dynamically changed objects. But still worth to use when someone needs it.
Brilliant!!!
I would say a very clean approach.
thanks Brandon, it's a nice idea. It's been very useful too!
Post a Comment