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

SelectedPoints on a Bar Chart

2 Answers 89 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 20 Feb 2014, 06:54 PM
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 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 Feb 2014, 07:19 PM
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
0
Paul
Top achievements
Rank 1
answered on 26 Feb 2014, 12:14 PM
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
Tags
ChartView
Asked by
Paul
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or