2011-08-05 16 views
1

I持って次のような問題:我々のアプリケーションで
我々は、実行時に定義されたサブカテゴリーでのレポートの一覧...レポートの
全体的な結果がの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

'' [Personality] '''私が言ったように、これはDictionary {...、{"Personality"、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

あなたはItemListの最初の項目のSections辞書に実際のエントリがあることを保証しまし"人"。エントリがない場合は、表示されているエラーが表示されます。ラインシリーズは、アイテムソースの最初のアイテムの値を使用して、使用する適切な軸を決定します。値がnullの場合は、記述したものと同様の例外が発生して失敗します(質問には正確なというエラーが表示されます)。

関連する問題