Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to add OxyPlot to a Xamarin Forms xaml Page

$
0
0

Hi.

Im trying to include oxyplot into a Xamarin.Forms-Project

This is my Xaml.cs file where Im building the PlotModel.

`
private void GeneratePlot()
{
var Points = new List
{
new DataPoint(0, 0),
new DataPoint(10, 5),
new DataPoint(20, 10),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 19)
};
var Points2 = new List
{
new DataPoint(0, 0),
new DataPoint(10, 7),
new DataPoint(20, 8),
new DataPoint(30, 8),
new DataPoint(40, 20),
new DataPoint(50, 25)
};
var m = new PlotModel();
m.PlotType = PlotType.XY;
m.InvalidatePlot(true);
m.Title = "hello oxy";
m.ResetAllAxes();
var ls1 = new LineSeries();
var ls2 = new LineSeries();
ls1.ItemsSource = Points;
ls2.ItemsSource = Points2;

    m.Series.Add(ls1);
    m.Series.Add(ls2);
    var _opv = new OxyPlotView
    {
        WidthRequest = 300,
        HeightRequest = 300,
        BackgroundColor = Color.Aqua
    };
    _opv.Model = m;
    PlModel = m;
}

`

In Code this works fine when I just put the OxyPlotModel _opy into a StackLayout. But when Im going to add it into Xaml like this:

<oxy:PlotView Model="{Binding Model}" VerticalOptions="Center" HorizontalOptions="Center" />

Im getting this Exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for OxyPlot.XamarinForms.PlotView ---> System.MissingMethodException: Method not found: 'Xamarin.Forms.BindableProperty.Create'

Does anyone know how to include oxyPlot into a XamlPage?

In my References Xamarin.Forms.Core and Xamarin.Forms.Xaml is Version 1.4 Xamarin.Forms.Platform is 1.0. OxyPlot and OxyPlot.XamarinForms is 2014.1.517.0

Thanks in advance.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>