2011-08-05 32 views
1

我有以下问题:
在我们的应用中有在运行时定义的子类别的报表列表...
报告的总体结果将显示在一个的ColumnSeries ,它工作正常。现在,我必须在LineSeries中显示子类别的结果以进行直接比较,这将不起作用。 这是我到目前为止(在后面的代码):Silverlight图表工具包:生成供LineSeries抛出异常

foreach (var item in ReportListViewModel.ReportSections) 
{ 
    var series = new LineSeries(); 
    series.SetBinding(DataPointSeries.ItemsSourceProperty, new Binding("ItemList")); 
    series.IndependentValuePath = "Date"; 
    series.DependentValuePath = item.BindingPath; // points to an existing entry in a Dictionary<string, double> 
    series.Title = item.Text; 
    chart.Series.Add(series); 
} 

它工作正常,但一旦数据被加载时,我得到一个InvalidOperationException异常,说明密谋值没有合适的轴被发现。

以下工作完全正常(即使它不正是我需要的):

foreach (...) 
{ 
    ... 
    series.DependentValuePath = "Result" // Result is the dependent property of the ColumnSeries, and I tested it just to make sure it isn't me 
    ... 
} 
+0

可不可以给的“item.BindingPath”的值的例子吗? – SalvadorGomez

+0

''部分[人格]“' 正如我所说,这是一个字典<字符串,双> {...,{”个性“,2.0},...} – Nuffin

回答

1

我不知道什么是不同的,但现在它的工作原理...

foreach (var item in ReportListViewModel.ReportSections) 
{ 
    var series = new LineSeries(); 
    series.SetBinding(DataPointSeries.ItemsSourceProperty, new Binding("ItemList")); 
    series.IndependentValuePath = "Date"; 
    series.DependentValuePath = item.BindingPath; 
    series.Title = item.Text; 
    chart.Series.Add(series); 
} 
1

你有没有保证,在Sections字典中ItemList的第一个项目的存在实际上是一个条目“个性”。如果没有条目,那么你看到的错误就是你会得到的。线条系列使用项目源中第一个项目的值来确定要使用的适当轴。如果该值为空,它将会失败,并出现与您所描述的类似的异常(您的问题中的错误是针对该错误的确切的措辞?)。