Если я использую IValueConverter
, он работает, в то время как IMultiValueConverter
возвращает то же значение, что и нет, почему?
<Border Background="Red" Width="100" Height="100"
CornerRadius="{Binding Converter={vc:SingleAndMultiConverter}}" />
<Border Background="Red" Width="100" Height="100"
CornerRadius="{MultiBinding Converter={vc:SingleAndMultiConverter}}" />
public class SingleAndMultiConverter : MarkupExtension, IValueConverter, IMultiValueConverter
{
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Convert();
}
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Convert();
}
private object Convert()
{
return 15;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
Мульти-связывание выдает эту ошибку:
Значение, созданное BindingExpression, недопустимо для целевого свойства .; Значение = '15'