SelectedPoints on a Bar Chart

3 posts, 0 answers
  1. Paul
    Paul avatar
    38 posts
    Member since:
    Feb 2014

    Posted 20 Feb 2014 Link to this post

    I am sure I am missing something, but I am not seeing any updates to my ViewModel for any selection changes.  I am getting the SelectionChanged Event in my code behind (which I don't want, I put it there for testing), but nothing through the binding. When I breakpoint on the event, and I look at the chart, the SelectedPoints property has the proper points in it.  Relevant things shown below.

    <telerik:RadCartesianChart x:Name="chart" Palette="Autumn" SelectedPoints="{Binding SelectedDataPoints, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">

    ....
    <telerik:RadCartesianChart.Series>
        <chartView:BarSeries ItemsSource="{Binding rgs}" PaletteMode="DataPoint" IsHitTestVisible="True" CategoryBinding="Name"
                 ValueBinding="Count">
           <chartView:BarSeries.PointTemplate>
              <DataTemplate>
                 <Rectangle Fill="{Binding Converter={StaticResource GoodToBad}}" />
              </DataTemplate>
           </chartView:BarSeries.PointTemplate>
       </chartView:BarSeries>
    </telerik:RadCartesianChart.Series>
    ....

    <telerik:RadCartesianChart.Behaviors>
         <telerik:ChartSelectionBehavior DataPointSelectionMode="Single" SelectionChanged="ChartSelectionBehavior_SelectionChanged" />
    </telerik:RadCartesianChart.Behaviors>

    and in my view model:

    private ReadOnlyDataPointCollection _dataPoints = null;
    public ReadOnlyDataPointCollection SelectedDataPoints
    {
        get { return _dataPoints; }
        set
        {
           _dataPoints = value;
           RaisePropertyChanged(() => SelectedDataPoints);
        }
    }

    There are no binding errors showing in the output window, and the "get" property on the SelectedDataPoints property in my view model is getting hit.  But never the set.

    What am I missing?

    Thank
    Paul


  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Feb 2014 Link to this post

    Hello Paul,

    I didn't managed to reproduce the same issue. So I attached the sample project in which i tried to reproduce what you describe. In order to track when you set the SelectedDataPoints property you can checkout the Output window of the Visual Studio. 

    If you want to track when the changes occur it might be a better idea to implement the EventToCommand pattern.

    Please let us know if this helps.

    Regards,
    Petar Mladenov
    Telerik
  3. UI for WPF is Visual Studio 2017 Ready
  4. Paul
    Paul avatar
    38 posts
    Member since:
    Feb 2014

    Posted 26 Feb 2014 in reply to Petar Mladenov Link to this post

    Thank you for the follow up.  I will check out your sample.  Like I said, I am sure it is something stupid I am missing.

    Paul
Back to Top