【发布时间】:2011-11-15 17:09:50
【问题描述】:
在我的 C#-WPF 应用程序中,我想用以下内容填充 WPF ColumnChart:
private void LoadPieChartData()
{
LinkedList<String> kostenstellen = rep.GetKostenstellen();
foreach (String s in kostenstellen)
{
((ColumnSeries)PieChart.Series[i]).ItemsSource =
new KeyValuePair<string, double>[]{
new KeyValuePair<string,double>(kostenstellen.ElementAt(i), i)
};
i++;
}
}
这是 xaml 代码:
<DVC:Chart HorizontalAlignment="Left" Margin="625,44,0,0" Name="PieChart" VerticalAlignment="Top" Height="276" Width="256" >
<DVC:Chart.Series>
<DVC:ColumnSeries ItemsSource="{Binding LoadPieChartData}" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" />
</DVC:Chart.Series>
</DVC:Chart>
我的问题是,我得到以下 XamlParseException:
'对'Finanz_WPF.MainWindow'类型的构造函数的调用 与指定的绑定约束匹配的会引发异常。
难道不能迭代 PieChart.Series 吗? 我可以通过什么方式来管理它?
【问题讨论】: