2012-10-09 2 views
0

몇 개의 체크 박스가 있습니다 (여기서 content = database의 이름). 메트릭에서 checkbox_checked가 wprf Chart에 ColumnSeries를 추가하려고했지만 여전히 오류가 발생했습니다. "개체 참조가 개체의 인스턴스로 설정되지 않았습니다."wpf 차트의 ColumnSeries에 ItemsSource를 추가하는 중 오류가 발생했습니다.

 <DVC:Chart Canvas.Top="80" Canvas.Left="10" Name="wykres1" Background="LightSteelBlue"> 

</DVC:Chart> 

그리고 코드 숨김 :

CheckBox c = (CheckBox)sender; 

      ColumnSeries b = new ColumnSeries(); 
      b.Title = c.Content.ToString(); 
      b.ItemsSource = null; 
      b.ItemsSource = 
       new KeyValuePair<string, int>[]{ 
        new KeyValuePair<string, int>("Project Manager", 12), 
        new KeyValuePair<string, int>("CEO", 25), 
        new KeyValuePair<string, int>("Software Engg.", 5), 
        new KeyValuePair<string, int>("Team Leader", 6), 
        new KeyValuePair<string, int>("Project Leader", 10), 
        new KeyValuePair<string, int>("Developer", 4) }; 
      wykres1.Series.Add(b); 

      categoryList.Add(c.Tag.ToString()); 

누구든지 도움이 될 수 있습니다 여기에

는 XAML 코드? :)

답변

1

이제 해고하십시오. 솔루션 : ColumnSeries b = new ColumnSeries {Title = c.Content.ToString(), IndependentValueBinding = 새 바인딩 ("키"), DependentValueBinding = 새 바인딩 ("값")};