【问题标题】:Silverlight charting toolkit: Generated LineSeries throws ExceptionSilverlight 图表工具包:生成的 LineSeries 引发异常
【发布时间】:2011-08-05 14:54:40
【问题描述】:

我有以下问题:
在我们的应用程序中,我们有一个报告列表,其中包含在运行时定义的子类别...
报告的总体结果显示在 ColumnSeries 中,效果很好。现在我必须在 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
    ...
}

【问题讨论】:

  • 你能举一个“item.BindingPath”值的例子吗?
  • "Sections[Personality]" 正如我所说,它是一个字典 { ..., {"Personality", 2.0},...}

标签: c# silverlight silverlight-4.0 charts silverlight-toolkit


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    我不知道有什么不同,但现在可以了...

    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);
    }
    

    【讨论】:

      猜你喜欢
      • 2011-02-14
      • 2011-09-20
      • 1970-01-01
      • 2013-03-16
      • 2012-01-20
      • 2011-10-24
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多