I'm using a custom class to perform validation in a WPF app and have defined a class which inherits from ValidationRule. The class has a dependancy which I would like AutoFac to inject at runtime, but the Visual Studio 2010 XAML designer needs a parameterless constructor in order to work.
It seems the only solution is to create a DependencyProperty for the dependency and bind it in XAML, but that means the dependency is publicly accessible and mutable, neither of which I want.
Is there any way to pass a dependency in to a class you intend to use in XAML which will do all of the following?
- Not break the designer.
- Keep the dependency private.
- Make sure the dependency is set before the class is used.