private void MyInfoWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Display tooltip of the clicked piece of chart
// reset previous result
if (highlightedChartPiece != null)
Unhighlight(highlightedChartPiece);
// get clicked element having tooltip
var point = e.GetPosition(null);
var element = VisualTreeHelper.FindElementsInHostCoordinates(point, popupContent).FirstOrDefault(elt => elt.GetValue(ToolTipService.ToolTipProperty) != null);
if (element == null)
{
// Add a tolerance since the piece of chart can be small
const double tolerance = 40;
Rect rect = new Rect(point.X - tolerance / 2, point.Y - tolerance / 2, tolerance, tolerance);
element = VisualTreeHelper.FindElementsInHostCoordinates(rect, popupContent).FirstOrDefault(elt => elt.GetValue(ToolTipService.ToolTipProperty) != null);
}
if (element != null)
{
// Display tooltip in chartDetails
chartDetailsContent.Content = element.GetValue(ToolTipService.ToolTipProperty);
Highlight(element);
}
}