Is your feature request related to a problem? Please describe.
Hello! I would like an addiction to the converters currently available with the addition of a ObjectMultiConverters that provides the same functionality as the ObjectConverters but for MultiBinding instead.
Describe the solution you'd like
The following would be possible with the new ObjectMultiConverters:
<Control.IsEnabled>
<MultiBinding Converter="{x:Static ObjectMultiConverters.AreAllEqual}">
<Binding ...></Binding>
<Binding ...><Binding>
</MultiBinding>
</Control.IsEnabled>
Describe alternatives you've considered
No response
Additional context
My Implementation for the class would be:
public static class ObjectMultiConverter
{
public static readonly IMultiValueConverter AreNull =
new FuncMultiValueConverter<object?, bool>(x => x.All(item => item is null));
public static readonly IMultiValueConverter AreNotNull =
new FuncMultiValueConverter<object?, bool>(x => x.All(item => item is not null));
public static readonly IMultiValueConverter AreAllEqual =
new FuncMultiValueConverter<object?, bool>(EqualityFunction);
public static readonly IMultiValueConverter AreNotEqual =
new FuncMultiValueConverter<object?, bool>(NotEqualityFunction);
private static bool EqualityFunction(IEnumerable<object?> values)
{
//Empty collection is considered equal, and a single value is equal to itself.
if (values.Count() == 0) return true;
if (values.Count() == 1) return true;
//Check if first item is equal to all others.
var firstValue = values.First();
var range = values.Skip(1);
foreach (var item in range)
if (item is null || !item.Equals(firstValue)) return false;
return true;
}
private static bool NotEqualityFunction(IEnumerable<object?> values) => !EqualityFunction(values);
}
Is your feature request related to a problem? Please describe.
Hello! I would like an addiction to the converters currently available with the addition of a
ObjectMultiConvertersthat provides the same functionality as the ObjectConverters but for MultiBinding instead.Describe the solution you'd like
The following would be possible with the new
ObjectMultiConverters:Describe alternatives you've considered
No response
Additional context
My Implementation for the class would be: