Chart Axis title: adding text to Binding value using StringFormat

3 posts, 0 answers
  1. Mark
    Mark avatar
    16 posts
    Member since:
    Sep 2012

    Posted 11 Jul 2013 Link to this post

    Sorry for such a simple question as I'm new to WPF but how do I add text to my axis title in front of my binding value?

    Here is my XAML that I'm trying:
    <telerik:LinearAxis Title="{Binding YAxisLabelDescription, StringFormat='Profit: {0}'}"/>

    My YAxisLabelDescription value is going to be "$" or "%" from my viewmodel. I would like to prepend the word "Profit" before the value in my XAML.

    The problem is the only thing showing up is "$" or "%".

    What am I missing?

    Thank you,
    Mark
  2. Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 16 Jul 2013 Link to this post

    Hi Mark,

    The issue that you are experiencing is related to the fact that it is expected to bind the Title property to a complex business object. If you use the following approach, you will achieve the desired effect.
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis Title="{Binding YAxisLabelDescription}">
            <telerik:LinearAxis.TitleTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding StringFormat=Total: {0}}" />
                </DataTemplate>
            </telerik:LinearAxis.TitleTemplate>
        </telerik:LinearAxis>
    </telerik:RadCartesianChart.VerticalAxis>


    Regards,
    Rosko
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mark
    Mark avatar
    16 posts
    Member since:
    Sep 2012

    Posted 16 Jul 2013 Link to this post

    Thank you Rosko that worked perfectly!
Back to Top