How to Style Label

4 posts, 1 answers
  1. Keaire
    Keaire avatar
    15 posts
    Member since:
    Nov 2013

    Posted 31 Mar 2014 Link to this post

    For some reason, I'm unable to apply a LabelText attribute on the RadDataBar. Its ControlTemplate contains a TextBlock which uses TemplateBinding to bind to the AppliedLabelMargin and LabelText properties, but they're not available.

    What gives?
  2. Answer
    Evgenia avatar
    1437 posts

    Posted 03 Apr 2014 Link to this post


    Indeed most of the properties in RadDatabar such as AppliedLabelMargin and LabelText have only getters and that's why you can't access them as direct properties of the DataBar. However you can retemplate the databar control and bind to custom business object properties so that custom text gets visualized. For example:

            <Style TargetType="telerik:RadDataBar">
                <Setter Property="Template">
                        <ControlTemplate TargetType="telerik:RadDataBar">
                            <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" >
                                    <dataBars:DataBarShape Fill="{TemplateBinding AppliedBarBrush}"
                                                        Style="{TemplateBinding BarStyle}"
                                                        Stroke="{TemplateBinding AppliedBarBorderBrush}"
                                                        StrokeThickness="{TemplateBinding BarBorderThickness}"
                                                        HeightPercent="{TemplateBinding BarHeightPercent}"
                                                        RightPercent="{TemplateBinding BarRightPercent}"
                                                        LeftPercent="{TemplateBinding BarLeftPercent}"
                                                        OutOfRangeRule="{TemplateBinding AppliedOutOfRangeRule}" />
                                    <ContentPresenter ContentTemplate="{TemplateBinding AppliedOutOfRangeTemplate}" />
                                    <Rectangle Margin="{TemplateBinding AppliedAxisMargin}"
                                             Fill="{TemplateBinding AxisStroke}"
                                             Style="{TemplateBinding AxisStyle}"
                                             Visibility="{TemplateBinding AppliedAxisVisibility}"
                                    <TextBlock Text="{Binding Name}"
                                           Style="{TemplateBinding LabelStyle}"
                                           Visibility="{TemplateBinding LabelVisibility}"
                                           Margin="{TemplateBinding AppliedLabelMargin}"
                                           VerticalAlignment="Center" />
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadDataBar Height="20" Value="{Binding Val}" OriginValue="20" BorderBrush="Gray" BorderThickness="1" Margin="2" ValueBrush="RoyalBlue" />

    And the business objects class:

    public partial class MainPage : UserControl
            public MainPage()
                this.DataContext = new Item() { Val = 40, Name = "My Product" };
            public class Item
                public double Val { get; set; }
                public string Name { get; set; }


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Christian
    Christian avatar
    1 posts
    Member since:
    Nov 2015

    Posted 17 Feb 2016 in reply to Evgenia Link to this post

    Hy Evgenia,


    im wondering where "dataBars:DataBarShape" is refernced to?

    Which refernce do i need to access DataBarShape?

    Thx in advance

  4. Evgenia
    Evgenia avatar
    1437 posts

    Posted 22 Feb 2016 Link to this post

    Hello Christian,

    You can easily see what is the exact namespace mapping that xmlns:databars points to if you open the default control template as we defined it in our themes. For the purpose you might use one of the approaches described here.

    I'm pasting it here for your ease:


    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 Feedback Portal and vote to affect the priority of the items
Back to Top