Line Series Chart Legend Issue

3 posts, 1 answers
  1. pratik mehta
    pratik mehta avatar
    17 posts
    Member since:
    May 2010

    Posted 27 Jul 2010 Link to this post

    Hi,

    In My application i am showing Context meny on click of legend item.
    Now i want to assign tag property of Legend item so i can know which legend is clicked. i do not want to create custom legend.



    Thanks

    Pratik Mehta
  2. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 27 Jul 2010 Link to this post

    Hi pratik mehta,

    You can achieve the desired functionality like this (note that it is essential to cast the ChartLegend to its base ItemsControl class in order to retrieve the legend items due to the specifics of the control implementation):

    public MainPage()
    {
        InitializeComponent();
     
        RadChart1.DataBound += this.RadChart1_DataBound;
        RadChart1.ItemsSource = new int[] { 1, 2, 3 };
    }
     
    private void RadChart1_DataBound(object sender, ChartDataBoundEventArgs e)
    {
        foreach (ChartLegendItem legendItem in (RadChart1.DefaultView.ChartLegend as System.Windows.Controls.ItemsControl).Items)
        {
            legendItem.Tag = "TEST";
        }
    }

    Hope this helps.


    Best wishes,
    Freddie
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. pratik mehta
    pratik mehta avatar
    17 posts
    Member since:
    May 2010

    Posted 29 Jul 2010 Link to this post

    Thanks , it works for me..
Back to Top