Xaml:
<lvc:CartesianChart x:Name="Teste" DataContext="{Binding}" Hoverable="False" Foreground="Black">
<lvc:CartesianChart.Series>
<lvc:ColumnSeries Title="{Binding OS}" Values="14" MaxWidth="1000" ColumnPadding="0" Foreground="Black"/>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding DESCRICAO}" Foreground="Black">
<lvc:Axis.Separator>
<lvc:Separator Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
CodeBehind:
private void LoadChart()
{
strConexao = ConfigurationManager.ConnectionStrings["BellaContext"].ConnectionString;
try
{
conn = new SqlConnection(strConexao);
conn.Open();
SqlCommand comm = new SqlCommand("SELECT * FROM PRODUTOS", conn);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(dt);
Teste.DataContext = dt.DefaultView;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
MessageBox.Show("Tudo Ok!");
}
}