This question is locked. New answers and comments are not allowed.
We are using ChartViews with AreaSeries to display summarized data over a period of time. We then utilize the ChartSelectionBehavior.SelectionChanged event to open a detailed report for the date corresponding to the point on the chart that was clicked. In testing, we noticed that after the initial time a point was clicked, it would take two clicks for each subsequent selection to be registered. We realized that was intended as the point was being toggled from selected to unselected each time it was clicked; so not a problem, we'll just reset the selection each time. That's where we are having trouble.
Here's some code to help explain the problem.
So you can see that we try to clear the selection so each time the user clicks on a point, it'll be treated as if it's being selected. But ClearSelection actually seems to exacerbate the issue. We can put in a breakpoint after that call and see that the SelectedPoints property of the chart is still populated. Clicking on the point again results in the event firing with both AddedPoints and RemovedPoints empty and the SelectedPoints collection still containing the point. Clicking once again fires the event with RemovedPoints populated with the point and SelectedPoints empty. Clicking one last time finally fires the event with AddedPoints populated.
Are we misunderstanding what ClearSelection does? If so, is there any way to implement what we are trying to do?
Here's some code to help explain the problem.
private
void
OnAreaChartSelected(
object
sender, ChartViewSelectionChangedEventArgs e)
{
var selectedPoint = e.AddedPoints.FirstOrDefault();
if
(selectedPoint ==
null
)
{
return
;
}
// Do some work
// Clear selection
var chartBehavior = sender
as
ChartSelectionBehavior;
if
(chartBehavior !=
null
)
chartBehavior.ClearSelection();
}
So you can see that we try to clear the selection so each time the user clicks on a point, it'll be treated as if it's being selected. But ClearSelection actually seems to exacerbate the issue. We can put in a breakpoint after that call and see that the SelectedPoints property of the chart is still populated. Clicking on the point again results in the event firing with both AddedPoints and RemovedPoints empty and the SelectedPoints collection still containing the point. Clicking once again fires the event with RemovedPoints populated with the point and SelectedPoints empty. Clicking one last time finally fires the event with AddedPoints populated.
Are we misunderstanding what ClearSelection does? If so, is there any way to implement what we are trying to do?