This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am using a Chart control to display a series of points as a scatter plot. When a data point is selected, I'd like a details view to be populated with detailed information about the point that was selected. Ideally, I'd like to bind the details panel as such: <ms:Chart> <ms:ScatterSeries Name="ChartSeries">...</ms:ScatterSeries> </ms:Chart> <StackPanel Name="PointDetailsPanel" DataContext="{Binding ElementName=ChartSeries, Path=SelectedDataPoint.DataContext}" > ... </StackPanel> However, this does not work because it seems that ScatterSeries (or its parent DataSeries) does not implement INotifyPropertyChanged. Therefore, I'm forced to handle the MouseLeftButtonDown event and manually wire up the details panel DataContext in the code behind. This is a less than ideal situation. Are there any plans to make this and/or other control properties available to the WPF data binding system and have them work as expected? Or am I completely missing something?
|
|
|
Hello Thanks for the feedback and sorry for the inconvenience. I have updated DataSeries to implement INotifyPropertyChanged so that binding to the SelectedDataPoint will now work. This update will be available through the nightly builds from tomorrow the 28th of April. Nightly builds for the trial version can be found here: http://assets.mindscape.co.nz/Trial/Nightlies/20110426/WpfElements4Trial-20110426.msi or go to your account page if you are a customer: http://www.mindscapehq.com/store/myaccount Regards |
|
|
Rather than implementing INotifyPropertyChanged, SelectedDataPoint will now be a dependency property instead. - Jason |
|
|
A dependency property should work just fine. Great customer service, thanks! |
|
|
I tried out the new DependencyProperty version of SelectedDataPoint. It *almost* works, but there's one more problem. My ScatterSeries ItemsSource is also bound to a source list. When the DataContext of the Chart changes, the ScatterSeries is redrawn to show the new data, but the SelectedDataPoint is still set to the previous data point which has been unloaded from the visual tree. I think the SelectedDataPoint should automatically be set to null in this case. Again, I came up with a code-behind workaround, to manually set the previous point's IsSelected to false, like so:
private void TheChart_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (ChartSeries.SelectedDataPoint != null) { ChartSeries.SelectedDataPoint.IsSelected = false; } } |
|
|
Hello and thanks for pointing this out. I have updated the logic to set the SelectedDataPoint property to null when appropriate. This fix will be available through the nightly builds from tomorrow the 29th of April. This will allow you to conveniently remove your local workaround. - Jason |
|