I need to implement MultiBindings in C# directly without using XAML, I know how to use the IMultiValueConverter in C#, but, how to do:
<MultiBinding Converter="{StaticResource sumConverter}">
<Binding ElementName="FirstSlider" Path="Value" />
<Binding ElementName="SecondSlider" Path="Value" />
<Binding ElementName="ThirdSlider" Path="Value" />
</MultiBinding>
in C# ?
Why not using XAML?
The following code should work:
MultiBinding multiBinding = new MultiBinding();
multiBinding.Converter = converter;
multiBinding.Bindings.Add(new Binding
{
ElementName = "FirstSlider",
Path = new PropertyPath("Value")
});
multiBinding.Bindings.Add(new Binding
{
ElementName = "SecondSlider",
Path = new PropertyPath("Value")
});
multiBinding.Bindings.Add(new Binding
{
ElementName = "ThirdSlider",
Path = new PropertyPath("Value")
});