WPF Toolkit Charting and IndependentValueBinding, IndependentValuePath

Posted by Joel Barsotti on Stack Overflow See other posts from Stack Overflow or by Joel Barsotti
Published on 2010-06-02T19:02:18Z Indexed on 2010/06/02 19:04 UTC
Read the original article Hit count: 644

Filed under:
|
|
|

So I'm having a problem with the charting engine from the WPF toolkit.

We haven't moved our data to a proper object model, so the ItemSource is backed with a DataView.

First attempt

<chartingToolkit:ScatterSeries x:Name="TargetSeries" DataPointStyle="{StaticResource TargetStyle}"  ItemsSource="{Binding Path=TargetSeriesData}"
                IndependentValueBinding="{Binding Path=TargetSeries_X}" DependentValueBinding="{Binding Path=TargetSeries_X}" />

This crashes because, I believe, it thinks the bindings are the values to plot or some sort of mismatch.

Second attempt

<chartingToolkit:ScatterSeries x:Name="TargetSeries" DataPointStyle="{StaticResource TargetStyle}"  ItemsSource="{Binding Path=TargetSeriesData}"
                IndependentValuePath="{Binding Path=TargetSeries_X}" DependentValuePath="{Binding Path=TargetSeries_X}" />

This crashes during the init step becaue the Path properties aren't backed with dependency properties and therefore cannot be bound.

Third attempt

<chartingToolkit:ScatterSeries x:Name="TargetSeries" DataPointStyle="{StaticResource TargetStyle}"  ItemsSource="{Binding Path=TargetSeriesData}"
                IndependentValuePath="targetFooXColumnName" DependentValuePath="targetFooYColumnName" />

Now this works! But I wanted to use the binding so I can switch from using the targetFooXColumnName to the targetFooBarXColumnName. So this solution will cause a whole lot of hacky looking code to switch the Path's manually.

Anyway to fix this? Can I use some sort of convertor to get the Binding properties to correctly pull the data from the columns in the DataView?

Thanks, Joel

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding