I'm working with OxyPlot in WPF and have some problems. I'm trying to create an app and want to use OxyPlot to create a chart. Everything works except that the plot/the data won't show up. I can't seem to figure out why.
Here is some of my xaml code:
<UserControl x:Class="myNameSpace.MainPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:app="clr-namespace:myNameSpace"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
d:DesignHeight="1200"
d:DesignWidth="1920">
<UserControl.DataContext>
<local:MainViewModel/>
</UserControl.DataContext>
....
<oxy:Plot Title="{Binding Title}" Margin="760,689,606,228" Width="504" Height="283">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
and my MainViewPanel class looks like this:
public class MainViewModel
{
public MainViewModel()
{
this.Title = "Example 2";
this.Points = new List<DataPoint>
{
new DataPoint(0, 4),
new DataPoint(10, 13),
new DataPoint(20, 15),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 12)
};
}
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
}
This is how the chart looks like when I run my code
I don't see local namespace prefix defined. If the MainViewModel is in the AnnaEmilie namespace, change local:MainViewModel
to app:MainViewModel