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

LegendLabel Binding

3 Answers 56 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Horst
Top achievements
Rank 1
Horst asked on 05 Jul 2011, 01:28 PM
I'd like to databind the LegendLabel to a field of my viewmodel.
<telerikCharting:SeriesMapping LegendLabel="{Binding ViewModelField}" >

When opening my window the Legend displays "Series 0" instead of the value from my ViewModelField. When I refresh the View by updating the ItemsSource of the RadChart control I get the LegendLabel value I want.

Any ideas of what is going wrong?
I'm using the Q1/2011 WPF chart control.

3 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 07 Jul 2011, 03:23 PM
Hi Horst,

Unfortunately we were unable to reproduce the problematic behavior in our local tests. Please review the attached sample application and let us know how can we observe the erroneous issue so we can advise you properly how to proceed.


Kind regards,
Giuseppe
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Muhammad Irfan
Top achievements
Rank 1
answered on 30 Nov 2011, 01:42 PM
Hi,
I go through your sample application and LegendLabel is binding in it. But if we assign View DataContext in code behind (instead of static in XAML) then it does not work even in your sample application.

Let me tell you exact step in your sample application to reproduce this issue.
Remove the following line from your "MainWindow.xaml"
<Window.DataContext>
        <demo:ViewModel />
    </Window.DataContext>

Now assign datacontext in constructor of "MainWindow.xaml.cs" like this.
public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new ViewModel();
        }

Why is this behavior? Any alternative to bind LegendLabel when we will have to assign DataContext through code?
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 05 Dec 2011, 10:41 AM
Hello Muhammad,

The equivalent of setting the DataContext in XAML would look like this in code-behind (move the setter prior to the InitializeComponent() call):
public MainWindow()
{
    this.DataContext = new ViewModel();
    InitializeComponent();
}


Greetings,
Bart.
Tags
Chart
Asked by
Horst
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Muhammad Irfan
Top achievements
Rank 1
Bartholomeo Rocca
Top achievements
Rank 1
Share this question
or