I am running into this problem which I cannot think of an easy way to solve.
Here is my XAML
<toolkit:Chart Height="250" x:Name="ProductSalesChart" >
<toolkit:Chart.Series>
<toolkit:StackedBarSeries>
<toolkit:SeriesDefinition Title="Series1" ItemsSource="{Binding ProductA}" IndependentValueBinding="{Binding Milestone}" DependentValueBinding="{Binding Sales}">
</toolkit:SeriesDefinition>
<toolkit:SeriesDefinition Title="Series2" ItemsSource="{Binding ProductB}" IndependentValueBinding="{Binding Milestone}" DependentValueBinding="{Binding Sales}">
</toolkit:SeriesDefinition>
<toolkit:StackedBarSeries.IndependentAxis>
<toolkit:CategoryAxis Orientation="X"></toolkit:CategoryAxis>
</toolkit:StackedBarSeries.IndependentAxis>
<toolkit:StackedBarSeries.DependentAxis>
<toolkit:LinearAxis Orientation="Y" ShowGridLines="True"></toolkit:LinearAxis>
</toolkit:StackedBarSeries.DependentAxis>
</toolkit:StackedBarSeries>
</toolkit:Chart.Series>
</toolkit:Chart>
So basically, its a stacked chart with milestones on X-axis and Number of sales for each product on Y-axis. I got this working except that the products I retrieve comes from database and it can get changed. In my chart above I have hardcoded it to two (Series1 and Series2). Is there any way to bind this series to a View model object so that it can automatically go up or down ?
Few options based on my findings:
a) Access the chart control from view model and programmatically add series. But doesn't this break MVVM. Also, how can I get a reference to the chart control from view model ? Is there any API for this ? Using event triggers is not working. (at least for the chart OnLoaded)
b) Create your own Chart class inheriting the basic one. How easy is this ? Any good sample ?
Any other ideas ?