I have an IValueConverter implemented class and I need it to be injected using my DI container (Ninject).
The problem is, in XAML, there\'s no immediately obvious way to
A common way to handle this is for your converter to also be a MarkupExtension
. That is:
public class MyConverter : MarkupExtension, IValueConverter
Your ProvideValue()
method can return an instance of your converter, thus allowing you to use it like this:
Source="{Binding CurrentMessage, Converter={local:MyConverter SomeParameterToConverter}}"
This isn't really anything to do with DI, but it does address your requirement to eliminate the code behind. I don't really see the point of having converters registered with your DI container.