Question

I have a WPF line series chart, when a datapoint is selected the selection changed event is fired.

What i want to know is, is there a way to give the datapoints ID values so that i can get them from inside the selection event

something like:

private void LineSeries_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
   int id = ((something)sender).id;
}
Was it helpful?

Solution

The SelectionChangedEventArgs should provide you the information you need. The property AddedItems contains the DataPoints that is/are selected and the property RemovedItems contains the DataPoints that where previously selected.

You need to cast the items in the collection to the Type (DataPoint or LineDataPoint for LineSeries)you need.

private void LineSeries_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
   DataPoint selectedPoint = null;

   if (e.AddedItems.Count > 0){
     selectedPoint = e.AddedItems[0];
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top