这是我在这里的第一篇文章,所以,很抱歉我提前犯了错误:)。这就是我的问题:我正在尝试使用MVVM模式构建一个WPF应用程序,但我并不总是能够在图表中加载数据。它唯一有效的时候就是我使用PieSeries的时候。在所有其他情况下,我收到一个错误。奇怪的是,在我的设计器窗口中可以看到我的图表。下面是我的代码:
<Border Background="White" BorderThickness="2" BorderBrush="Black" Grid.Column="1">
<!--ContentPresenter Content="{Binding Path=FormHost}">
</ContentPresenter-->
<Grid>
<chart:Chart Name="chart1">
<chart:Chart.Series>
<chart:PieSeries Name="series1" ItemsSource="{Binding ChartItems}"
IndependentValueBinding="{Binding Path=Name}"
DependentValueBinding="{Binding Path=Value}"/>
</chart:Chart.Series>
</chart:Chart>
</Grid>
</Border>在viewModel中,我有其他一些东西:
private ObservableCollection<ChartElement> chartItems;
public MainWindowViewModel()
{
chartItems = new ObservableCollection<ChartElement>();
chartItems.Add(new ChartElement("da011111111111", 3));
chartItems.Add(new ChartElement("adas111111", 490));
chartItems.Add(new ChartElement("adas111111", 341));
chartItems.Add(new ChartElement("adas111111", 413));
chartItems.Add(new ChartElement("adas111111", 143));
}带有错误的图像

提前谢谢你。
https://stackoverflow.com/questions/17127848
复制相似问题