WPF工具包:使用对象数据提供程序将图表绑定到dataview

WPF工具包:使用对象数据提供程序将图表绑定到dataview,wpf,binding,charts,dataview,toolkit,Wpf,Binding,Charts,Dataview,Toolkit,我正在尝试使用从DataSet表返回的Dataview创建图表。我在C#中创建了一个数据提供程序对象,它使用从数据源向导创建的数据集和表适配器。数据提供程序对象有一个方法,该方法在填充表后返回表的默认视图 数据检索部分工作正常,如果将datagrid绑定到它,我就能够看到数据。我的问题是,如何将dataview绑定到柱状图(或任何图表)?我的独立数据是dataview中的一个文本列,依赖数据是一个数字量。运行此代码时,会出现如下运行时错误: 集合属性 'System.Windows.Contro

我正在尝试使用从DataSet表返回的Dataview创建图表。我在C#中创建了一个数据提供程序对象,它使用从数据源向导创建的数据集和表适配器。数据提供程序对象有一个方法,该方法在填充表后返回表的默认视图

数据检索部分工作正常,如果将datagrid绑定到它,我就能够看到数据。我的问题是,如何将dataview绑定到柱状图(或任何图表)?我的独立数据是dataview中的一个文本列,依赖数据是一个数字量。运行此代码时,会出现如下运行时错误:

集合属性 'System.Windows.Controls.DataVisualization.Charting.DataPointSeries.DependentValueBinding' 引发异常。行号“17”和行位置“18”

我做错了什么

<Window xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"  xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"   x:Class="GraphingTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:GraphingTest"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <ObjectDataProvider ObjectType="{x:Type local:CustomDataProvider}"  x:Key="odp1">            
        </ObjectDataProvider>
        <ObjectDataProvider ObjectInstance="{StaticResource odp1}" MethodName="GetQualitativeData" x:Key="odp2">

        </ObjectDataProvider>
    </Window.Resources>
    <ScrollViewer>
    <StackPanel DataContext="{Binding Source={StaticResource odp2}}">
            <chartingToolkit:Chart  >
                <chartingToolkit:ColumnSeries DependentValueBinding="MyNumberValue" IndependentValueBinding="MyTextLabel" ItemsSource="{Binding}">

                </chartingToolkit:ColumnSeries>

            </chartingToolkit:Chart>
        </StackPanel>
    </ScrollViewer>
</Window>

应该是:

<chartingToolkit:ColumnSeries DependentValueBinding="{Binding MyNumberValue}" IndependentValueBinding="{Binding MyTextLabel}" ItemsSource="{Binding}"> 


<chartingToolkit:ColumnSeries DependentValueBinding="MyNumberValue" IndependentValueBinding="MyTextLabel" ItemsSource="{Binding}"> 
<chartingToolkit:ColumnSeries DependentValueBinding="{Binding MyNumberValue}" IndependentValueBinding="{Binding MyTextLabel}" ItemsSource="{Binding}"> 
<chartingToolkit:ColumnSeries DependentValuePath="MyNumberValue" IndependentValuePath="MyTextLabel" ItemsSource="{Binding}">