ApplyValueConverter
is defined as a static Func<>
delegate in the ConventionManager
class.
In order to provide your own converter in convention-binding scenarios, you need to define your own Func<>
in the Configure()
method of your bootstrapper, something like this:
NOTE: I am assuming the conversion is from string
to Opacity
.
public class AppBootstrapper : Bootstrapper<ShellViewModel> {
private static IValueConverter StringToOpacityConverter = new StringToOpacityConverter();
public override void Configure() {
var oldApplyConverterFunc = ConventionManager.ApplyValueConverter;
ConventionManager.ApplyValueConverter = (binding, bindableProperty, property) => {
if (bindableProperty == UIElement.Opacity && typeof(string).IsAssignableFrom(property.PropertyType))
// ^^^^^^^ ^^^^^^
// Property in XAML Property in view-model
binding.Converter = StringToOpacityConverter;
// ^^^^^^^^^^^^^^^^^^^^^^^^^
// Our converter used here.
// else we use the default converter
else
oldApplyConverterFunc(binding, bindableProperty, property);
};
}
}