这篇文章不错。没有废话,几秒钟就能扫完。
<MultiBinding Converter="{StaticResource sumConverter}">
<Binding ElementName="FirstSlider" Path="Value" />
<Binding ElementName="SecondSlider" Path="Value" />
<Binding ElementName="ThirdSlider" Path="Value" />
</MultiBinding>
public class SumConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
double total = 0;
foreach (double val in values)
total += val;
return total.ToString();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}