Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
Get clicked item in xamdatachart spline series
posted

Hi,

I have a xamdatachart with a spline series. When the user clicks on the line in the chart, I need to get the item that was clicked and use it in my view model. 

I have bound a command to the MouseLeftButtonDown event and as long as the user clicks on one of the marks on the line everything is fine, I get the item from the DataContext. But when the user clicks on the line between the marks I only get a SeriesDataContext which has no info about the item behind the value. How can I get the item when the line is clicked?

Regards,

Hilma

private void OnMouseLeftButtonDown(MouseEventArgs args)
{
var shape = (Shape)args.OriginalSource;
MyItem item = null;

if (shape.DataContext is DataContext infragisticsDataContext)
{
Item = (MyItem)infragisticsDataContext.Item ;
}
else
{
var otherDataContext = (SeriesDataContext)shape.DataContext;
// ??? How do I det MyItem now?
}

this.MyMethod(item);
}