简体   繁体   English

如何多重绑定到IValueConverter?

[英]How to multiple binding to IValueConverter?

On UWP(Windows 10 platform), IMultiValueConverter is not supported. 在UWP(Windows 10平台)上,不支持IMultiValueConverter

How to multiple binding for this textblock 如何对该文本块进行多重绑定

<TextBlock x:Name="txtContentMessage"
           Text="{Binding Text}"
           TextTrimming="CharacterEllipsis" 
           TextWrapping="Wrap"
           Foreground="{Binding Entities,
               ConverterParameter={Binding Text},
               Converter={StaticResource ChangedColorToUrlConverter},
               Mode=TwoWay}"
           MaxLines="3"
           Grid.Row="1"/>

As per MDSN forum you can use DependencyProperty . 根据MDSN论坛,您可以使用DependencyProperty

Or, one of the method described by Magnus, bind a list of values and use a converter. 或者,使用Magnus描述的方法之一,绑定values列表并使用转换器。

public IList<object> Values
{
   get { return new List<object> { this.Entities, this.Text }; }
}

XAML: XAML:

<TextBlock x:Name="txtContentMessage"
           Text="{Binding Text}"
           TextTrimming="CharacterEllipsis" 
           TextWrapping="Wrap"
           Foreground="{Binding Values,
               Converter={StaticResource ChangedColorToUrlConverter},
               Mode=TwoWay}"
           MaxLines="3"
           Grid.Row="1"/>

And write Convert for the List object. 并为List对象编写Convert

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM