を表示しません、私はどこにでもXAMLでそれの証拠は、実行時にチャートの100%を作成しようとしています。ページのロード時にそうするために、私は空白のチャートを作成:のSilverlight 4のチャートは、Silverlightの4ツールキットのチャートコントロールを使用してデータ
Chart TrendChart = new Chart();
TrendChart.Name = "TrendChart";
TrendChart.Title = "Call History";
TrendChart.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
TrendChart.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
TrendChart.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
TrendChart.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
GridPanel.Children.Add(TrendChart);
ユーザーが一覧は、このカスタムクラスの作成され、データを取得するために、ボタンをクリックした後:私が使用
private class PhoneTrendDataPoint
{
public string XValue { get; set; }
public double YValue { get; set; }
}
私のチャートのItemsSourceとして、CurrentCallTrendsと呼ばれるそのリスト。
// Update the chart with the received data
Chart TrendChart = (Chart)this.FindName("TrendChart");
// Wipe out previous chart data
TrendChart.Series.Clear();
// set the data
ColumnSeries columnSeries = new ColumnSeries();
columnSeries.Name = "Current Call Volume";
columnSeries.ItemsSource = CurrentCallTrends;
//columnSeries.SetBinding(ColumnSeries.ItemsSourceProperty, new Binding("CurrentCallTrends"));
columnSeries.DependentValueBinding = new Binding("XValue");
columnSeries.IndependentValueBinding = new Binding("YValue");
TrendChart.Series.Add(columnSeries);
問題は、私はそれがオブジェクトのインスタンスに設定されていないオブジェクト参照に関するデバッガを開くために私を促し、ランタイムエラーを取得するということです。私が行を.SetBindingにコメントすると、ItemsSourceは消滅し、データは表示されませんが、少なくとも実行時エラーはありません。
私には何が欠けていますか?
「CurrentCallTrends」とは何ですか? – ChrisF
私はこれをクラスのトップに宣言しました。これは次のとおりです。プライベートList CurrentCallTrends =新しいList (); –