如何将wpf折线图绑定到数据表?

时间:2011-04-29 15:44:22

标签: c# wpf binding datatable charts

这是xaml代码:

<graphs:Chart x:Name="Chart2" Margin="0,236,412,12" HorizontalAlignment="Right" Width="417" BorderBrush="Black" DataContext="{Binding}" Grid.ColumnSpan="5">
            <graphs:LineSeries ItemsSource="{Binding}"
                DependentValuePath="PAPER"
                IndependentValuePath="DATES"
                Title="Paper" IsSelectionEnabled="True" />
            <graphs:LineSeries ItemsSource="{Binding}"
                DependentValuePath="PLASTIC"
                IndependentValuePath="DATES"
                Title="Plastic" IsSelectionEnabled="True" />
            <graphs:LineSeries ItemsSource="{Binding}"
                DependentValuePath="GLASS"
                IndependentValuePath="DATES"
                Title="Glass" IsSelectionEnabled="True" />
            <graphs:LineSeries ItemsSource="{Binding}"
                DependentValuePath="METALS"
                IndependentValuePath="DATES"
                Title="Metals" IsSelectionEnabled="True" />
            <graphs:LineSeries ItemsSource="{Binding}"
                DependentValuePath="FABRIC"
                IndependentValuePath="DATES"
                Title="Fabric" IsSelectionEnabled="True" />
            <graphs:Chart.Axes>
                <graphs:LinearAxis
                                Orientation="Y"
                                Minimum="0"
                                Maximum="1000"
                                ShowGridLines="True"/>
                <graphs:CategoryAxis
                                Orientation="X"
                                ShowGridLines="True"
                                />
            </graphs:Chart.Axes>
        </graphs:Chart>

c#代码是:

Chart2.DataContext = ad;

数据表是从一个sql查询填充的,当我在网格视图上绑定它时它显示得很好,但是当我尝试将它绑定到图表时,没有任何显示......

0 个答案:

没有答案