我想你需要的是MultiBinding。
尝试创建一个转换器类是这样的:
public class MultiBindingConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return values[0].ToString() + " " + values[1].ToString();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
参考它在你的App.xaml或其他资源字典
<local:MultiBindingConverter x:Key="MultiBindingConverter" />
然后做这样的事情在你的视野:
<Label>
<Label.Content>
<MultiBinding Converter="{StaticResource MultiBindingConverter}">
<Binding Path="FirstProperty" />
<Binding Path="SecondProperty" />
</MultiBinding>
</Label.Content>
</Label>
FirstProperty和SecondProperty只是ViewModel中的常规属性。
看起来像转换器('IValueConverter')的工作给我... – Milen
然后你在执行它吗? :) – NullReference