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

HELP!!! Custom Label for Radial Gauge

1 Answer 129 Views
Gauges
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 04 Mar 2012, 04:35 PM
I need to be able to add a Custom Label to a Radial Gauge that will contain text indicating the status of the value being presented.  I am using the WPF Q2 2011 gauges and because of a time crunch I will not be able to upgrade the gauges to a newer version.  I know that the next version of gauge has this ability.  Please if anyone knows how to add a text label as indicated I need to know this quickly.  Thank you for your time and consideration on this question.

James

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 08 Mar 2012, 08:55 AM
Hello James,

You can use the CustomTickMark element to show the label of the value. I would recommend to create additional scale which will contain this element for ability to set the label properties like Location separately. The sample code is below.
private void CreateRadialGaugeWithValueLabel()
{
    RadialGauge gauge = new RadialGauge();
 
    LayoutRoot.Children.Add(gauge);
 
    RadialScale radialScale = new RadialScale()
    {
        Label = new LabelProperties()
        {
            Location = ScaleObjectLocation.Inside
        }
    };
    gauge.Items.Add(radialScale);
 
    RadialScale customTickMarkScale = new RadialScale()
    {
        MajorTicks = -1,
        Label = new LabelProperties()
        {
            Location = ScaleObjectLocation.Outside
        }
    };
    gauge.Items.Add(customTickMarkScale);
 
    Marker marker = new Marker()
    {
        Location = ScaleObjectLocation.OverCenter,
        RelativeWidth = 0.1,
        RelativeHeight = 0.1,
        Value = 85
    };
 
    customTickMarkScale.Indicators.Add(marker);
 
    CustomTickMark tick = new CustomTickMark()
    {
        Format = "{0:F2}",
        Template = null
    };
 
    Binding binding = new Binding();
    binding.Source = marker;
    binding.Path = new PropertyPath("Value");
    tick.SetBinding(CustomTickMark.ValueProperty, binding);
 
    customTickMarkScale.Ticks.Add(tick);
}

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