Creating multiple gauges

2 posts, 0 answers
  1. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 06 Jul 2010 Link to this post

    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);  
                    
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Jul 2010 Link to this post

    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
  3. DevCraft banner
Back to Top