This is a migrated thread and some comments may be shown as answers.

Set Gauge Ranges Programatically

3 Answers 97 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
jfkrueger asked on 18 May 2011, 07:08 PM
I am very new to Silverlight so please forgive me if this is an incredibly basic question. I have a gauge with 4 ranges. I do not know some of the min/max values at design time so I enter values as placeholders. When the control fires up, I am updating the values based on data passed in from a WCF service. Everything sets correctly and no errors are thrown, but the gaugue is never updated with the new ranges. Here is my xaml:

<telerik:RadGauge Name="RadGaugeOverallQuality"
            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <telerik:RadialScale x:Name="radialScale" Min=".5" Max="1.5" MajorTickStep=".1">
                            <telerik:RangeBase Name="RangeOverallQualitySignificantlyBad" Min=".5" Max=".75" IndicatorBackground="DarkRed" />
                            <telerik:RangeBase Name="RangeOverallQualityStandardBad" IndicatorBackground="Red" Min=".75" Max="1" />
                            <telerik:RangeBase Name="RangeOverallQualityStandardGood" IndicatorBackground="Green" Min="1" Max="1.25" />
                            <telerik:RangeBase Name="RangeOverallQualitySignificantlyBetter" IndicatorBackground="LimeGreen" Min="1.25" Max="1.5" />
                            <telerik:RadialBar Name="bar" 
                               Value="20" />
                            <telerik:Needle x:Name="gauge1_needle" IsAnimated="true" Value="0"   />
                            <telerik:MajorTickProperties />
                            <telerik:LabelProperties FontSize="10" Format="{}{0:F2}"  />
                        <RowDefinition Height="0.60*" />
                        <RowDefinition Height="0.40*" />
                    <TextBlock Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center"
                            Foreground="GhostWhite" FontFamily="CourierNew">

Here is the code:

RangeOverallQualitySignificantlyBad.Min = .5
        RangeOverallQualitySignificantlyBad.Max = lResult("OverallQualityIndexConfidenceIntervalMin")
        RangeOverallQualityStandardBad.Min = lResult("OverallQualityIndexConfidenceIntervalMin")
        RangeOverallQualityStandardBad.Max = 1
        RangeOverallQualityStandardGood.Min = 1
        RangeOverallQualityStandardGood.Max = lResult("OverallQualityIndexConfidenceIntervalMax")
        RangeOverallQualitySignificantlyBetter.Min = lResult("OverallQualityIndexConfidenceIntervalMax")
        RangeOverallQualitySignificantlyBetter.Max = 1.5

Can someone please enlighten me as to why this code has no effect and show me the proper way to update ranges in code?


3 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 18 May 2011, 08:09 PM
Not sure if this is the right way to do it or not but here is what I have figured out:

1) Completely removed the definitions for the ranges from the markup
2) Programatically added the ranges:

'Set ranges for Overall Quality Index Guage
radialScale.Ranges.Add(New RadialRange With {.Min = .8, .Max = lResult("OverallQualityIndexConfidenceIntervalMin"), .Background=New SolidColorBrush(Colors.Magenta), .StartWidth=.05, .EndWidth=.15})
radialScale.Ranges.Add(New RadialRange With {.Min = lResult("OverallQualityIndexConfidenceIntervalMin"), .Max = 1, .Background=New SolidColorBrush(Colors.Red), .StartWidth=.15, .EndWidth=.2})
radialScale.Ranges.Add(New RadialRange With {.Min = 1, .Max = lResult("OverallQualityIndexConfidenceIntervalMax"), .Background=New SolidColorBrush(Colors.Green), .StartWidth=.2, .EndWidth=.15})
radialScale.Ranges.Add(New RadialRange With {.Min = lResult("OverallQualityIndexConfidenceIntervalMax"), .Max = 1.20, .Background=New SolidColorBrush(Colors.Orange), .StartWidth=.15, .EndWidth=.05})

I would much rather define the ranges in the markup and just update the min and max values in code like I was trying to do originally so if someone knows how to make that work that would be awesome. This works but one thing that is strange is that I don't have the full range of colors to select from. From the markup I can select "DarkRed", "LightGreen", etc but in code I only have a very limited selection of colors to choose from. It telle me that "DarkRed" is not a member of System.Windows.Media.Colors.

I'm getting to where I want to be, but I feel like i'm kind of just hacking my way through it without knowing the best way to do what I'm trying to accomplish.

Any help would be greatly appreciated.

Telerik team
answered on 23 May 2011, 02:36 PM
Hi jfkrueger,

I checked your XAML and your VB snippets and I found that in XAML RangeList contains RangeBase elements (which is OK, but they are invisible and serve special cases), but in your VB code you add RadialRange to the RangeList. RadialRange is visible element. If you change your XAML to use RadialRange instead of RangeBase it will work fine.

Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Top achievements
Rank 1
answered on 24 May 2011, 07:18 PM
That works great, thank you!
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Telerik team
Share this question