Won't Fix
Last Updated: 18 Oct 2018 10:23 by ADMIN
ADMIN
Pavel R. Pavlov
Created on: 07 May 2014 11:53
Category: Gauge
Type: Bug Report
1
Gauge: Binding of GaugeRange's properties does not work as expected
When the properties are bound in code behind, they are not updated as they are supposed to.

Binding them in XAML, by setting the DataContext of the control as StaticResource, works as expected.
1 comment
ADMIN
Kalin
Posted on: 18 Oct 2018 10:22
Hi,

After investigation appeared that this is framework behavior of the Freezable objects in WPF. We use Freezable objects in the control in order to inherit the DataContext as explained in the following article:
http://drwpf.com/blog/2008/05/22/leveraging-freezables-to-provide-an-inheritance-context-for-bindings/

It works as expected until the DataContext is set after the binging has been evaluated and broken - it won't work anymore.
This is how the issue is reproduced - if the DataContext is set after InitializeComponent - the binding stops working.

As a solution we recommend binding the property through the DataContext of the Gauge instance. For example check the following XAML:

<telerik:RadRadialGauge x:Name="xGauge">
    <telerik:RadialScale>
        <telerik:RadialScale.Ranges>
            <telerik:GaugeRange 
                                Background="Red" 
                                Max="{Binding DataContext.Max, ElementName=xGauge}" 
                                Min="{Binding DataContext.Min, ElementName=xGauge}" />
        </telerik:RadialScale.Ranges>
    </telerik:RadialScale>
</telerik:RadRadialGauge>

And in code behind the DataContext is set in after InitializeComponent():
public MainWindow()
{
	InitializeComponent();
        this.DataContext = new MyViewModel(20, 80);
}

I'm changing the Status to Won't Fix - please use the suggested solution. However if this doesn't help - please contact us.

Kalin