OK here is what I'm trying to do. I need multiple list charts in a single chart control. No problem that's easy enough using Sheog's answer on this post:
https://stackoverflow.com/a/10604545/1836291
The problem is that I don't know how many charts i need until run-time. So my idea is to put it into an items control and set the data template as a LineSeries like so:
<ItemsControl x:Name="pieChart">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<chartingToolkit:Chart DataContext="{Binding}" Title="Pie Series Demo" Margin="0" Background="#FF48474B" Height="400"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
And my data:
List<KeyValuePair<string, int>> valueList = new List<KeyValuePair<string, int>>();
valueList.Add(new KeyValuePair<string, int>("Developer", 60));
valueList.Add(new KeyValuePair<string, int>("Misc", 20));
valueList.Add(new KeyValuePair<string, int>("Tester", 50));
valueList.Add(new KeyValuePair<string, int>("QA", 30));
valueList.Add(new KeyValuePair<string, int>("Project Manager", 40));
List<KeyValuePair<string, int>> valueList2 = new List<KeyValuePair<string, int>>();
valueList2.Add(new KeyValuePair<string, int>("Developer", 40));
valueList2.Add(new KeyValuePair<string, int>("Misc", 40));
valueList2.Add(new KeyValuePair<string, int>("Tester", 40));
valueList2.Add(new KeyValuePair<string, int>("QA", 40));
valueList2.Add(new KeyValuePair<string, int>("Project Manager", 20));
var dataSourceList = new List<List<KeyValuePair<string, int>>>();
dataSourceList.Add(valueList);
dataSourceList.Add(valueList2);
pieChart.DataContext = dataSourceList;
My feeling is that the problem lies somewhere in my databinding but, I don't know enough about it to troubleshoot it.
Well I found this:
Programmatically create a ColumnSeries WPF Toolkit Charts
and it does in fact work quite nicely but, i'd still like to know how to do this in XAML.
Thank you,