[英]How to set ItemsSource value of ColumnSeries?
I am not able to set ItemsSource
value of ColumnSeries
. 我无法设置
ColumnSeries
ItemsSource
值。 I am following some examples ( this and this ) but they seem to be out dated. 我正在跟踪一些示例( this和this ),但它们似乎已过时。
Here is my XAML
: 这是我的
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>
and here is my C#
code: 这是我的
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;
}
I am getting the following error: 我收到以下错误:
Error 1 The type or namespace name 'ColumnSeries' could not be found (are you missing a using directive or an assembly reference?)
错误1找不到类型或名称空间名称'ColumnSeries'(您是否缺少using指令或程序集引用?)
I have also try: 我也尝试过:
ColumnChartSeries.ItemsSource = personalData;
But get: 但是得到:
An exception of type 'System.NullReferenceException' occurred in gotqn.exe but was not handled in user code.
gotqn.exe中发生了'System.NullReferenceException'类型的异常,但未在用户代码中处理。
Also, I am getting the following error often: 另外,我经常遇到以下错误:
Error 1 A value of type 'ColumnSeries' cannot be added to a collection or dictionary of type 'Collection`1'.
错误1无法将'ColumnSeries'类型的值添加到'Collection`1'类型的集合或字典中。
but I am able to run the application, so I guess it is not critical. 但我能够运行该应用程序,因此我认为它并不关键。
Could you tell what I am doing wrong? 你能告诉我我做错了吗?
Also, I will be grateful for being given some good up-to-dated documentation link/article. 另外,我将非常感谢您获得一些最新的文档链接/文章。
Perhaps you're missing this in your code behind... 也许您在代码中缺少此功能...
using WinRTXamlToolkit.Controls.DataVisualization.Charting;
Try moving your cursor to ColumnSeries
and press Alt+Shift+F10 to add the missing namespace. 尝试将光标移动到
ColumnSeries
,然后按Alt + Shift + F10添加缺少的名称空间。 Or simply use Alt+Enter if you have ReSharper (which I recommend). 或者,如果您拥有ReSharper(我建议使用),则只需使用Alt + Enter。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.