LegendLabel Binding

4 posts, 0 answers
  1. Horst
    Horst avatar
    3 posts
    Member since:
    Jun 2011

    Posted 05 Jul 2011 Link to this post

    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.
  2. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 07 Jul 2011 Link to this post

    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,
    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!

  3. DevCraft R3 2016 release webinar banner
  4. Muhammad Irfan
    Muhammad Irfan avatar
    18 posts
    Member since:
    Jan 2010

    Posted 30 Nov 2011 Link to this post

    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"
            <demo:ViewModel />

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

    Why is this behavior? Any alternative to bind LegendLabel when we will have to assign DataContext through code?
  5. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 05 Dec 2011 Link to this post

    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();

Back to Top