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

Creating multiple gauges

1 Answer 58 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
madladuk
Top achievements
Rank 2
madladuk asked on 06 Jul 2010, 11:38 AM
I have a user control that creates multiple gauges, however when I view the page I can only see one gauge, if I use Silverlight Spy I can see that both the gauges have been created, so I must be doing something wrong! ;

 void drawRadialGauge(DataRow dr)  
        {  
            try  
            {  
                RadialScale scale;  
                Needle needle;  
                StackPanel stackpanel = new StackPanel()  
                {  
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Left,  
                    VerticalAlignment = System.Windows.VerticalAlignment.Top  
                };  
 
                // create the RadGauge  
                RadGauge radGauge = new RadGauge()  
                {  
                    Name = String.Format("Gauge_{0}_{1}", dashitem.uniqueid, i.ToString()),  
                    Width = 250,  
                    Height = 250 
                };  
 
                // add RadGauge to the LayoutRoot  
                stackpanel.Children.Add(radGauge);  
 
                // create the RadialGauge  
                var gauge = new RadialGauge();  
                // add RadialGauge to the RadGauge  
                radGauge.Content = gauge;  
 
                // create the RadialScale  
                scale = new RadialScale()  
                {  
                    Name = String.Format("Scale_{0}_{1}", dashitem.uniqueid, i.ToString()),  
                    Min = Convert.ToDouble(dashitem.minvalue),  
                    Max = Convert.ToDouble(dashitem.maxvalue),  
                    EndWidth = 0.1,  
                    StartWidth = 0.1,  
                    MiddleTicks = 2,  
                    MinorTicks = 2,  
                    Radius = 0.75d  
                };  
 
                // add RadialScale to the RadialGauge  
                gauge.Items.Add(scale);  
 
                // create the Needle  
                needle = new Needle()  
                {  
                    Name = String.Format("Needle_{0}_{1}", dashitem.uniqueid, i.ToString()),  
                    IsAnimated = true,  
                    Value = Convert.ToDouble(dr[dashitem.yfield]),  
                };  
                // add needle to indicators collection  
                scale.Indicators.Add(needle);  
 
                // create the Needle  
                RadialBar bar = new RadialBar()  
                {  
                    Name = String.Format("Bar_{0}_{1}", dashitem.uniqueid, i.ToString()),  
                    IsAnimated = true,  
                    Value = Convert.ToDouble(dr[dashitem.yfield]),  
                };  
                // add needle to indicators collection  
                scale.Indicators.Add(bar);  
 
                                     
                }  
                LayoutRoot.Children.Add(stackpanel);  
                

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 06 Jul 2010, 05:45 PM
Hello Paul,

Per row you add each gauge to own stack panel and then you add the stack panel to the LayoutRoot element. I think it is a Grid. So, each next gauge is placed over the previous one.

Regards,
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
Tags
Gauge
Asked by
madladuk
Top achievements
Rank 2
Answers by
Andrey
Telerik team
Share this question
or