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

Chart Axis title: adding text to Binding value using StringFormat

2 Answers 172 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 11 Jul 2013, 01:55 PM
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 Answers, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 16 Jul 2013, 07:56 AM
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 >>
0
Mark
Top achievements
Rank 1
answered on 16 Jul 2013, 11:36 AM
Thank you Rosko that worked perfectly!
Tags
Chart
Asked by
Mark
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Mark
Top achievements
Rank 1
Share this question
or