Adding Chart series dynamicly.

Jun 27, 2013 at 12:44 AM
i am trying to add series dynamicly (from outside html) to a chart ive created in XML.

However i cannot seem to get it right:

here is my XML:
<chart:StackedColumnChart
                        Name="stacked"
                        Style="{StaticResource MinimalChartStyle}"
                        ChartTitle="Stacked?"
                        ChartSubTitle="wtf"
                        SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}">
                        <chart:StackedColumnChart.Series>
                            <chart:ChartSeries
                                SeriesTitle="stacked bar"
                                DisplayMember="Category"
                                ValueMember="Number"
                                ItemsSource="{Binding Path=SeriesData}">
                            </chart:ChartSeries>
                        </chart:StackedColumnChart.Series>
                    </chart:StackedColumnChart>        
And here is my mainWindow():
public partial class MainWindow : Window
    {
        public ObservableCollection<SeriesData> Series = new ObservableCollection<SeriesData>();
        public ObservableCollection<TestClass> Errors { get; set; }
        public MainWindow()
        {

            this.DataContext = this;

            Errors = new ObservableCollection<TestClass>();
            Errors.Add(new TestClass() { Category = "Globalization", Number = 75 });
            Errors.Add(new TestClass() { Category = "Features", Number = 2 });
            Errors.Add(new TestClass() { Category = "Features", Number = 55 });
            Errors.Add(new TestClass() { Category = "ContentTypes", Number = 12 });
            Errors.Add(new TestClass() { Category = "Correctness", Number = 83 });
            Errors.Add(new TestClass() { Category = "Best Practices", Number = 29 });

            Series.Add(new SeriesData() { SeriesDisplayName = "Errors", Items = Errors });
            
      //      InitializeComponent();
        }
        private object selectedItem = null;
        public object SelectedItem
        {
            get
            {
                return selectedItem;
            }
            set
            {
                // selected item has changed
                selectedItem = value;
            }
        }
    }
    public class TestClass
    {
        public string Category { get; set; }

        public int Number { get; set; }
    }

    public class SeriesData
    {
        public string SeriesDisplayName { get; set; }

        public string SeriesDescription { get; set; }

        public ObservableCollection<TestClass> Items { get; set; }
    }
}
Can anyone tell me what im doing wrong?
Jul 23, 2013 at 11:21 AM
 foreach (var chart in items)
                {
                    var items = new List<ChartItem>();
                    items.Add(new ChartItem() { Category = "gesamt", Number = chart.UMSATZ_GESAMT });
                    items.Add(new ChartItem() { Category = "Vorjahr", Number = chart.UMSATZ_GESAMT });

                    Series.Add(new SeriesData() { SeriesDisplayName = chart.NAME, Items = items});
                }