我有问题将数据正确绑定到WPF图表 . 当我设置ItemsSource时,我收到错误:
不能使用指定的从属轴 . 数据可能无法在提供的轴上呈现,或者系列可能要求它们的轴具有原点 .
oc = new ObservableCollection<Pair>();
heartBeats.ItemsSource = oc;
配对我保存int和long
XAML:
...
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" >
<charting:Chart x:Name="ApplicatioChart">
<charting:Chart.Series>
<charting:ColumnSeries x:Name="heartBeats" Title="Working Set"
DependentValueBinding="{Binding First}" IndependentValueBinding="{Binding Second}" >
<charting:ColumnSeries.IndependentAxis>
<charting:CategoryAxis Orientation="X" />
</charting:ColumnSeries.IndependentAxis>
<charting:ColumnSeries.DependentRangeAxis>
<charting:LinearAxis Orientation="Y" />
</charting:ColumnSeries.DependentRangeAxis>
</charting:ColumnSeries>
</charting:Chart.Series>
</charting:Chart>
请帮忙.. :(
2 回答
我这样解决了:
标记不能看到任何错误(除了相同的属性被绑定为依赖值和独立值) .
它似乎在Silverlight版本中运行良好,我没有WPF版本可以使用 .
尝试删除DependentRangeAxis的定义,以查看它是否与默认值一起使用 .