Hi Gertjan,
I've added a code that creates ranges to the CreateGauge method. I hope it helps.
private RadGauge CreateGauge()
{
// create the RadGauge
var radGauge = new RadGauge()
{
Width = 300,
Height = 300 * 0.59d
};
// create the RadialGauge
var gauge = new RadialGauge();
// add RadialGauge to the RadGauge
radGauge.Content = gauge;
// create the RadialScale
var scale = new RadialScale()
{
Min = 0,
Max = 100,
EndWidth = 0.1,
StartWidth = 0.1,
MiddleTicks = 2,
MinorTicks = 2,
Radius = 1.2d,
};
// add RadialScale to the RadialGauge
gauge.Items.Add(scale);
// load theme to setup semicircular styles
var uri = new Uri("/Telerik.Windows.Controls.Gauge;component/Themes/generic.xaml", UriKind.Relative);
var dictionary = new ResourceDictionary();
dictionary.Source = uri;
// setup semicircular style to the gauge
if (dictionary.Contains("RadialGaugeHalfCircleNStyle"))
{
gauge.Style = dictionary["RadialGaugeHalfCircleNStyle"] as Style;
}
// setup semicircular style to the scale
if (dictionary.Contains("RadialScaleHalfCircleNStyle"))
{
scale.Style = dictionary["RadialScaleHalfCircleNStyle"] as Style;
}
// add ranges
scale.Ranges.Add(new RadialRange()
{
Min = 0,
Max = 29.99,
Location = ScaleObjectLocation.Inside,
StartWidth = 0.05,
EndWidth = 0.05,
Background = new SolidColorBrush(Colors.Red)
});
scale.Ranges.Add(new RadialRange()
{
Min = 30,
Max = 59.99,
Location = ScaleObjectLocation.Inside,
StartWidth = 0.05,
EndWidth = 0.05,
Background = new SolidColorBrush(Colors.Yellow)
});
scale.Ranges.Add(new RadialRange()
{
Min = 60,
Max = 100,
Location = ScaleObjectLocation.Inside,
StartWidth = 0.05,
EndWidth = 0.05,
Background = new SolidColorBrush(Colors.Green)
});
return radGauge;
}
All the best,
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.