Hi. Thank you for your answer. It seems I have been a bit unclear in my explanation, my apologies. Comments are added in the file to clarify, and the code is modified to give an example of what I tried first.
private void GenerateSeries()
{
if (Source == null || (SeriesTemplateSelector == null && SeriesTemplate == null)) return;
var commonItemsSource = (Source as IEnumerable).GetEnumerator();
List<string> LegendCollection = new List<string>();
while (commonItemsSource.MoveNext())
{
ChartSeries series = null;
//The conditions checked for setting the SeriesTemplate or SeriesTemplateSelector.
if (SeriesTemplate != null)
{
series = SeriesTemplate.LoadContent() as ChartSeries;
}
if (LegendCollection.Contains((commonItemsSource.Current as AnnualPriceData).DataType))
series.VisibilityOnLegend = Visibility.Collapsed;
else
LegendCollection.Add((commonItemsSource.Current as AnnualPriceData).DataType);
series.DataContext = commonItemsSource.Current;
Series.Add(series);
}
}
|