Create a RadVerticalLinearGauge in runtime

2 posts, 0 answers
  1. Diego Alejandro
    Diego Alejandro avatar
    3 posts
    Member since:
    Mar 2009

    Posted 22 Mar 2012 Link to this post

    Hello,

    I'm trying to create a RadVerticalLinearGauge in runtime, I've made it but I cannot set the properties for NumericIndicator such as telerik:ScaleObject.RelativeWeight. How can I do this?

    This is what I want to do:

    <telerik:NumericIndicator Format="{}{0:F0}"
                                Value="60"
                                telerik:ScaleObject.RelativeWidth="0.4"
                                telerik:ScaleObject.RelativeHeight="0.1"
                                telerik:ScaleObject.RelativeX="0.6"
                                telerik:ScaleObject.RelativeY="0.1">
                            <telerik:NumericIndicator.Positions>
                                <telerik:SevenSegsNumberPosition />
                                <telerik:SevenSegsNumberPosition />
                                <telerik:SevenSegsNumberPosition />
                            </telerik:NumericIndicator.Positions>
                        </telerik:NumericIndicator>

    And, this is my code:
    RadVerticalLinearGauge radVertical = new RadVerticalLinearGauge();
     
    LinearScale linearScale = new LinearScale();
    linearScale.Min = 0;
    linearScale.Max = 100;
    linearScale.LabelLocation = ScaleObjectLocation.Outside;
                         
    radVertical.Items.Add(linearScale);
     
    BarIndicator barIndicator = new BarIndicator();
    barIndicator.Name = "gaugeIndicator";
    barIndicator.Value = 50;
                         
    NumericIndicator numericIndicator = new NumericIndicator();
    numericIndicator.Format = "{}{0:F0}";
    numericIndicator.Value = 60;
     
    /*I WANT TO ADD THE SCALEOBJECT PROPERTIES HERE FOR numericIndicator*/
     
    linearScale.Indicators.Add(numericIndicator);
    linearScale.Indicators.Add(barIndicator);
                         
    Border verticalBorder = new Border();
    verticalBorder.BorderThickness = new Thickness(1,0,0,0);
    verticalBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 51, 102, 153));
                         
     
    linearScale.CustomItems.Add(verticalBorder);

    I've found this thread: http://www.telerik.com/community/forums/silverlight/gauge/numberindicator.aspx, it is using an oldest release (Q1 2010). I need the same thing using a newer version. I have version 2011.3.1220.1040.

     If anyone can help me, I'll be very thankful.
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 27 Mar 2012 Link to this post

    Hello Diego Alejandro,

    All these properties are attachable dependency properties, so you can set them from code behind using standard Silverlight approach with ScaleObject.SetPropertyName methods. For example, to set ScaleObject.RelativeWidth property you can use the following call:

    ScaleObject.SetRelativeWidth(numericIndicator, 0.4);


    All the best,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
Back to Top