I'm having a very difficult time understanding what's actually supposed to be happening with LiveCharts. I have a block of XAML here:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/CPF;component/Images/background-top-cropped2.png" Stretch="None"></ImageBrush>
</Grid.Background>
<lvc:CartesianChart Series="{Binding myData}" LegendLocation="Right" x:Name="myChart">
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Sales" LabelFormatter="{Binding YFormatter}"></lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis Title="Month" Labels="{Binding Labels}"></lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
</Grid>
And code Behind here:
public MainWindow()
{
InitializeComponent();
DrawGraphs();
}
public void DrawGraphs()
{
LineSeries mySeries = new LineSeries
{
Values = new ChartValues<int> { 12, 23, 55, 1 }
};
myChart.Series.Add(mySeries);
}
At runtime, 'myChart.Series.Add(mySeries)' throws a Null Reference Exception error. I'm unsure of how to resolve this?