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

How to add the SegmentedRadialGaugeIndicator by code?

1 Answer 71 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
javier
Top achievements
Rank 1
javier asked on 06 Feb 2011, 08:33 PM
Hi there,


How to add the following items to a RadialGaugeRange by code (during runtime)?:
-SegmentedRadialGaugeIndicator
-ArrowGaugeIndicator
-DataTemplate

I have trie dout this code but it does not work:

                    RadialGaugeRange rgr = new RadialGaugeRange();
                    rgr.MinAngle = -75;
                    rgr.MaxAngle = 255;
                    rgr.TickStep=100;
                    rgr.MajorTickStep=150;
                    rgr.LabelStep=100;
                    rgr.LabelRadiusScale = 0.95;
                    rgr.TickRadiusScale = 0.75;
                    rgr.HorizontalAlignment=System.Windows.HorizontalAlignment.Center;
                    rgr.VerticalAlignment=System.Windows.VerticalAlignment.Center;

                    ArrowGaugeIndicator arrow = new ArrowGaugeIndicator();
                    arrow.ArrowThickness = 2;
                    arrow.ArrowTailRadius = 1.4;
                    //arrow.ArrowColor = Colors.Yellow;
                    arrow.Value = g.Kpi.Value;                   
                    rgr.Indicators.Add(arrow);

                    RadialGaugeRange rangeArrow = new RadialGaugeRange();
                    rangeArrow.MinAngle = 180;
                    rangeArrow.MaxAngle = 360;
                    //RadialGaugeRange.IndicatorRadiusScaleProperty = 0.31;
                    rgr.Children.Add(rangeArrow);

                    SegmentedRadialGaugeIndicator ind = new SegmentedRadialGaugeIndicator();
                    BarIndicatorSegment seg1=new BarIndicatorSegment();
                    seg1.Length=2;
                    seg1.Thickness=3;

                    BarIndicatorSegment seg2 = new BarIndicatorSegment();
                    seg2.Length = 1.66;
                    seg2.Thickness = 3;

                    BarIndicatorSegment seg3 = new BarIndicatorSegment();
                    seg3.Length = 2.34;
                    seg3.Thickness = 3;
                   
                    ind.Segments.Add(seg1);
                    ind.Segments.Add(seg2);
                    ind.Segments.Add(seg3);

                    rgr.Children.Add(ind);

                    Grid.SetRow(rgr, 1);
                    Grid.SetColumn(rgr, 0);
                    newGrid.Children.Add(rgr);

By other hand, how can I assing these properties:
arrow.ArrowColor = Colors.Yellow;
RadialGaugeRange.IndicatorRadiusScaleProperty = 0.31;

Thank you,


Javier Andrés Cáceres Alvis
Windows Phone - MVP
@jacace

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 09 Feb 2011, 12:36 PM
Hello javier,

Thank you for your interest in our gauges for Windows Phone 7.

The ArrowColor property is of type Brush hence you can not set it to a value of type Color. The naming however is misleading and we will change it in our official version to "ArrowBrush".

The IndicatorRadiusScale is an attached dependency property, you can set it to a value on an indicator like so:

RadialGaugeRange.SetIndicatorRadiusScale(arrow, 0.31);

Here is your code, slightly modified. I have highlighted the changed lines:
RadialGaugeRange rgr = new RadialGaugeRange();
rgr.MinAngle = -75;
rgr.MaxAngle = 255;
rgr.TickStep = 100;
rgr.MajorTickStep = 150;
rgr.LabelStep = 100;
rgr.LabelRadiusScale = 0.95;
rgr.TickRadiusScale = 0.75;
 
ArrowGaugeIndicator arrow = new ArrowGaugeIndicator();
arrow.ArrowThickness = 2;
arrow.ArrowTailRadius = 1.4;
arrow.ArrowColor = new SolidColorBrush(Colors.Yellow);
arrow.Value = 20;
rgr.Indicators.Add(arrow);
 
RadialGaugeRange rangeArrow = new RadialGaugeRange();
rangeArrow.MinAngle = 180;
rangeArrow.MaxAngle = 360;
RadialGaugeRange.SetIndicatorRadiusScale(arrow, 0.31);
 
SegmentedRadialGaugeIndicator ind = new SegmentedRadialGaugeIndicator();
BarIndicatorSegment seg1 = new BarIndicatorSegment();
seg1.Stroke = new SolidColorBrush(Colors.Red);
seg1.Length = 2;
seg1.Thickness = 3;
BarIndicatorSegment seg2 = new BarIndicatorSegment();
seg2.Stroke = new SolidColorBrush(Colors.Green);
seg2.Length = 1.66;
seg2.Thickness = 3;
BarIndicatorSegment seg3 = new BarIndicatorSegment();
seg3.Stroke = new SolidColorBrush(Colors.Blue);
seg3.Length = 2.34;
seg3.Thickness = 3;
ind.Segments.Add(seg1);
ind.Segments.Add(seg2);
ind.Segments.Add(seg3);
ind.Value = 100;
 
rgr.Indicators.Add(ind);
Grid.SetRow(rgr, 1);
Grid.SetColumn(rgr, 0);
this.grid.Children.Add(rgr);
rgr.Children.Add(rangeArrow);

I hope this helps. Do not hesitate to contact us with any question and/or suggestion you may have - feedback is most welcome.

Regards,
Victor
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Gauge
Asked by
javier
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or