wpf simple chart data binding to sql stored procedure

Aug 30, 2010 at 8:57 PM




I'm trying to create a simple bar chart with data coming from a stored procedure on a sql server. This my code for getting the data into a datatable:


SqlConnection cn = new SqlConnection("Data Source=xxx;Initial Catalog=yyy;User=abcd;Password = 1234")


 DataTable dt = new DataTable("Report");


 SqlCommand cm = new SqlCommand("dbo.usp_GetData"

, cn);



cm.Parameters.AddWithValue("@prm1", 1 );  



cm.CommandType = CommandType .StoredProcedure; 

SqlDataAdapter da = new SqlDataAdapter (cm);



) CapacityChart.Series[0]).ItemsSource = dt.DefaultView;


On the chart itself, I have this as my XAML:


 <DVC:Chart x:Name="myChart" Background="AliceBlue" Margin="110,39,26,6" DataContext="{Binding






<DVC:ColumnSeries Title ="Capacity"

 IndependentValueBinding="{Binding Path=value1}"


DependentValueBinding="{Binding Path =value2}" >






I don't get an error message, but I don't get a chart either. What is it that I'm missing? Is there a simple way to bind a dataset or datatable to the chart?