我认为您需要的是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 中的常规属性。