2016-12-01 28 views
0

在UWP(Windows 10平臺)上,不支持IMultiValueConverter如何多重綁定到IValueConverter?

如何將多個這種文本塊

<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"/> 

回答

0

MDSN forum可以使用DependencyProperty結合。

或者,Magnus描述的方法之一綁定一列values並使用轉換器。

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

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"/> 

而寫ConvertList對象。