Advice developers to use shorter and nicer IValueConvert syntax instead of old WPF-style
maxkatz6 opened this issue · 0 comments
maxkatz6 commented
Topics to cover
Many developers don't like IValueConverters because of their verbosity.
They need to create an instance of a class, implement two-way methods, add it to the resources, and so on.
Instead, we should let them know that it's possible to use converters with x:Static and FuncValueConverter.
Simple examples:
public static class IntConverters
{
public static FuncValueConverter<int, bool> IsNotZero { get; } = new(i => i != 0);
}
<Image Grid.Column="0" Source="/Assets/checkmark.png" Width="28" Height="28"
IsVisible="{Binding Value.Count, Converter={x:Static converters:IntConverters.IsNotZero}}" />
That's it.
I haven't checked our documentation and all samples. But in general, that's what we can recommend for one-way IValueConverter and IMultiValueConverter. Additionally, we should add FuncValueConverter two-way conversion support.