Apr 9, 2010 at 7:31 AM
Edited Apr 9, 2010 at 7:32 AM
Hi - I want to let my users choose what type of series they want to add at runtime. Currently I have hardcoded my chart like this...
ColumnSeries cs = new ColumnSeries();
cs.Title = dR["attribute"].ToString();
cs.IndependentValueBinding = new Binding("Key");
cs.DependentValueBinding = new Binding("Value");
cs.ItemsSource = aSeries.ToArray(typeof(KeyValuePair<string, decimal>));
...where dR is a DataRow and aSeries is an ArrayList. How can I dynamically set the series type. If I use an If condition to first add a series and later try to set the attributes... something like this...
(sType == "Bar")
BarSeries s =
ColumnSeries s =
Chart1.Series[Chart1.Series.Count - 1].Title = "My Title";
...I cannot set the Title, ItemsSource, etc. attributes, unless I use Casting. Since I don't know the variable until runtime, what can I do?