Charting: DataPointStyle Binding

Aug 26, 2009 at 12:30 PM

Hi all!

I have a question about the DataPointStyle of a ColumnSeries for example.

I have a UserControl with one chart and the chart have one ColumnSeries. Now I would like to bind the DataPointStyle to a property in my ViewModel so the UserControl is a bit  more generic.

But it don´t work that way. My chart  use the default style. Is there a way to assign style to the series?



Aug 27, 2009 at 1:44 AM

I don't think I understand the problem. :( ColumnSeries.Style should accept a Style/TargetType=ColumnSeries which will style the Series. Is that not working for you?

Aug 27, 2009 at 7:15 AM

Sorry for the bad description.

I would like to write something like this.

                ItemsSource="{Binding MainContent}"
                DependentValueBinding="{Binding Value}"
                IndependentValueBinding="{Binding Name}"
                DataPointStyle="{Binding ChartStyle}">

The properties "MainContent" and "ChartStyle" are properties from my viewModel. But the DataPointStyle-Binding don´t work. It works just with Static- or DynamicResource.

Aug 27, 2009 at 7:31 PM

I think I know what's going on here - the DataPointStyle is only used by a Series when it's creating the DataPoints - and if it changes later, the DataPoints are not updated with the new Style. So I think your Binding is just getting applied *after* the DataPoints have been created and therefore it seems not to work. So the fix would be to see if you can get that Binding in place *before* the DataPoints are set - perhaps by making sure MainContent gets set after ChartStyle is.

PS - Good news is that the next release of Charting has some fixes that should make the original scenario work fine because the DataPoint changes will automatically propagate everywhere they should go. :)

Aug 28, 2009 at 8:25 AM

Thanks for your response!

I tried to set the MainContent after the Style but it don´t work too. If I add the complete ColumnSeries from code then all Bindings work fine but that´s not what I´m looking for. I think I have to wait for the next release.