I am working on custom control.
I have three dependency property as mentioned below. Now depending on the control height, width and a range provided by the user, I have to calculate a value and display it in the custom control.
I am trying to use a multibinding where I can bind all these three values and my multivalue converter will do some calculation on this and returns me the appropriate value.
The problem is I do not know to bind this value in the styles as multivalue converter binding.
Dependency Properties:
public static readonly DependencyProperty ControlHeightProperty =
DependencyProperty.Register("ControlHeight", typeof(double), typeof
(TestControl), new PropertyMetadata(150D));
public double ControlHeight
{
get { return (double)GetValue(ControlHeightProperty); }
set { SetValue(ControlHeightProperty, value); }
}
public static readonly DependencyProperty ControlWidthProperty =
DependencyProperty.Register("ControlWidth", typeof (double), typeof
(TestControl), new PropertyMetadata(default(double)));
public double ControlWidth
{
get { return (double) GetValue(ControlWidthProperty); }
set { SetValue(ControlWidthProperty, value); }
}
public static readonly DependencyProperty RangeProperty =
DependencyProperty.Register("Range", typeof (double), typeof
(TestControl), new PropertyMetadata(default(double)));
public double Range
{
get { return (double) GetValue(RangeProperty); }
set { SetValue(RangeProperty, value); }
}
Style (I have not written the binding): If the properties are available in the same style than I can do it using ElementName binding. But in this case atlease may be for height and width it is possible. But Range is a direct dependency property which I have to bind in my style (I mean there is no way I can do an ElementName binding)
<TextBlock Grid.Row="1">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource
CalculateConverter}">
<Binding Path=""></Binding>
<Binding Path=""></Binding>
<Binding Path=""></Binding>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
Can someone help me?
Thanks & Regards,