4

我有一个来自Win RT Xaml Toolkit的图表,我想显示这样的 ColumnSeries:

<charting:Chart Name="columnChart" Grid.Row="1" Grid.Column="1" Width="400" Height="400">
    <charting:Chart.Series>
        <charting:ColumnSeries  
             ItemsSource="{Binding items}"
             IndependentValueBinding="{Binding Name}"
             DependentValueBinding="{Binding Value}" 
             IsSelectionEnabled="True">
        </charting:ColumnSeries>  
    </charting:Chart.Series>
</charting:Chart>

但我总是收到这个错误:

WinRT 信息:无法将“WinRTXamlToolkit.Controls.DataVisualization.Charting.ColumnSeries”类型的实例添加到“System.Collections.ObjectModel.Collection<WinRTXamlToolkit.Controls.DataVisualization.Charting.ISeries>”类型的集合中

这可能是什么原因?

4

1 回答 1

4

好的,我找到了,

错误是ColumnSeries缺少Title属性,如下所示:

<charting:Chart Name="columnChart" Grid.Row="1" Grid.Column="1" Width="400" Height="400">
    <charting:Chart.Series>
        <charting:ColumnSeries  
             Title="Chart Title"
             ItemsSource="{Binding items}"
             IndependentValueBinding="{Binding Name}"
             DependentValueBinding="{Binding Value}" 
             IsSelectionEnabled="True">
        </charting:ColumnSeries>  
    </charting:Chart.Series>
</charting:Chart>

似乎Title属性是强制性的。

于 2013-03-24T11:47:51.947 回答