Given this class:
namespace My.App.Converters
{
[ValueConversion(typeof(bool?), typeof(Visibility))]
public class NullableBooleanToVisibilityConverter : IValueConverter
{
...
}
}
Why do I have to do the following:
<UserControl ...
xmlns:converters="clr-namespace:My.App.Converters">
<UserControl.Resources>
<converters:NullableBooleanToVisibilityConverter x:Key="visibilityConverter" />
</UserControl.Resources>
...
<Button MinWidth="120" HorizontalAlignment="Left"
Visibility="{Binding BackButtonVisible, Converter={StaticResource visibilityConverter}}" />
...
</UserControl>
instead of being able to do something like the following:
<UserControl ...
xmlns:converters="clr-namespace:My.App.Converters">
...
<Button MinWidth="120" HorizontalAlignment="Left"
Visibility="{Binding BackButtonVisible, ConverterType={x:Type converters:NullableBooleanToVisibilityConverter}}" />
...
</UserControl>
given that I only ever want to use this particular converter in a single place in my app, i.e. this particular UserControl
?
Is the answer as simple as "Microsoft didn't feel like adding a ConverterType
and you can do it yourself with markup extensions if you really want", or is there a reason of good programming style for doing it this way? ("Reusability" doesn't count for this example.)