SelectionChanged in a BarSeries?

4 posts, 0 answers
  1. D Warren
    D Warren avatar
    10 posts
    Member since:
    Jul 2012

    Posted 20 Jul 2012 Link to this post

    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
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 25 Jul 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Xue Kun
    Xue Kun avatar
    2 posts
    Member since:
    Dec 2012

    Posted 05 Feb 2013 Link to this post

    Hi Petar,

    Is there an example using MVVM and doing the method in the ViewModel rather than the codebehind?
  5. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 08 Feb 2013 Link to this post

    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.

Back to Top