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

Line Series Chart Legend Issue

2 Answers 79 Views
Chart
This is a migrated thread and some comments may be shown as answers.
pratik mehta
Top achievements
Rank 1
pratik mehta asked on 27 Jul 2010, 11:57 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 27 Jul 2010, 05:05 PM
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
0
pratik mehta
Top achievements
Rank 1
answered on 29 Jul 2010, 12:52 PM
Thanks , it works for me..
Tags
Chart
Asked by
pratik mehta
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
pratik mehta
Top achievements
Rank 1
Share this question
or