سؤال

I have a chart which I would like to allow the user to select a data point which will select the corresponding item in a datagrid via view model.

I am binding to the SelectedItem on the LineSeries, mode TwoWay but it is not firing off the setter in my view model at all although the getter is clearly working as selecting a value in the datagrid highlights the correct data point.

<chartingToolkit:Chart>
    <chartingToolkit:LineSeries DependentValuePath="Status"
                                IndependentValuePath="DateTaken"
                                ItemsSource="{Binding OverallStatus}"
                                SelectedItem="{Binding SelectedTrendPoint, Mode=TwoWay}">
</chartingToolkit:Chart>

What's wrong with my chart???

هل كانت مفيدة؟

المحلول

It looks like the binding on your LineSeries is fine, but the WPF-Toolkit LineSeries has a flag IsSelectionEnabled which is false by default. If you set this flag then you will see the binding working. Add IsSelectionEnabled="True" to your LineSeries Try this:

<chartingToolkit:Chart>
    <chartingToolkit:LineSeries DependentValuePath="Status"
                                IndependentValuePath="DateTaken"
                                ItemsSource="{Binding OverallStatus}"
                                SelectedItem="{Binding SelectedTrendPoint, Mode=TwoWay}" 
                                IsSelectionEnabled="True"/>
</chartingToolkit:Chart>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top