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

SelectionChanged in a BarSeries?

3 Answers 178 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
D Warren
Top achievements
Rank 1
D Warren asked on 20 Jul 2012, 11:36 PM
Hello,

I am using the ChartView with several BarSeries and want to show a popup, when a certain bar is selected.
What's the recommended way to accomplish this?

I was looking at http://www.telerik.com/help/silverlight/radchartview-features-selection.html and tried to use the SelectionChanged event. However, it never gets fired.

I also tried retemplating the BarSeries.PointTemplate and using a transparent Button that overlays the Bar.
However, the Button's command is never invoked - not even when I set the BarSeries' HitTestVisible to true.

Thank you

3 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 25 Jul 2012, 01:07 PM
Hello,

It seems quite strange that the SelectionChanged event doesn't get fired. Can you provide some code so we can trace the source of the problem?

Can you confirm that you have implemented the following:
  • Subscribe to the event: 
    <telerik:RadCartesianChart.Behaviors>
        <telerik:ChartSelectionBehavior DataPointSelectionMode="Single"
            SelectionChanged="chartView_SelectionChanged"/>
    </telerik:RadCartesianChart.Behaviors>
  • Implement an event handler with same signature:
    private void chartView_SelectionChanged(object sender, ChartSelectionChangedEventArgs e)
    {
        //Handle de-selection of the current point
        if (e.RemovedPoints.Count > 0)
        {
            var removedPoint = e.RemovedPoints[0];
            var series = removedPoint.Presenter as BarSeries;    
      
            //Your code here    
        }
      
        //Handle selection of the current point
        if (e.AddedPoints.Count > 0)
        {
            var addedPoint = e.AddedPoints[0];
            var series = addedPoint.Presenter as BarSeries;
             
            //Your code here...
        }
    }


All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Xue Kun
Top achievements
Rank 1
answered on 05 Feb 2013, 07:54 AM
Hi Petar,

Is there an example using MVVM and doing the method in the ViewModel rather than the codebehind?
0
Petar Kirov
Telerik team
answered on 08 Feb 2013, 09:17 AM
Hi Xue Kun,

The ChartSelectionBehavior does not expose a SelectionChanged command which you can bind to your ViewModel, however you may use MVVM Light's EventToCommand behavior.

I hope this helps.

Greetings,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
D Warren
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Xue Kun
Top achievements
Rank 1
Share this question
or