我無法設置ItemsSource
的值ColumnSeries
。我正在關注一些示例(this和this),但它們似乎已過時。如何設置ColumnSeries的ItemsSource值?
這裏是我的XAML
:
<Charting:Chart x:Name="ColumnChart"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="Auto"
Height="Auto">
<Charting:ColumnSeries Title="Georgi Kyuchukov"
Margin="0"
Name="ColumnChartSeries"
IndependentValuePath="Name"
DependentValuePath="Pts"
IsSelectionEnabled="True" />
</Charting:Chart>
這裏是我C#
代碼:
public class ChartData
{
public string Name { get; set; }
public int Pts { get; set; }
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
List<ChartData> personalData = (List<ChartData>)e.Parameter;
foreach (ChartData x in personalData){
Debug.WriteLine(x.Name + " " + x.Pts);
}
(ColumnChart.Series[0] as ColumnSeries).ItemsSource = personalData;
//ColumnChartSeries.ItemsSource = personalData;
}
我收到以下錯誤:
Error 1 The type or namespace name 'ColumnSeries' could not be found (are you missing a using directive or an assembly reference?)
我也有嘗試:
ColumnChartSeries.ItemsSource = personalData;
但得到:
An exception of type 'System.NullReferenceException' occurred in gotqn.exe but was not handled in user code.
而且,我收到以下錯誤常:
Error 1 A value of type 'ColumnSeries' cannot be added to a collection or dictionary of type 'Collection`1'.
但我能跑應用程序,所以我想這不是關鍵。
你能說出我做錯了什麼嗎?
此外,我將不勝感激給予一些良好的最新文檔鏈接/文章。