There are dozens of issues about this particular problem, but none of the proposed solutions have worked for me. I cannot get OxyPlot to appear in iOS or Android. I've followed the setup instructions to add the various Init methods after Xamarin Forms init. What I have tried so far:
I am using Xamarin Android version 25.4.0.2, Xamarin Forms 2.4.0.18342, and OxyPlot version 1.0.0.
Here's the XAML:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"
x:Class="Example.Stats"
NavigationPage.HasNavigationBar="false">
<ContentPage.Content>
<AbsoluteLayout>
<oxy:PlotView Model="{Binding Model}"
AbsoluteLayout.LayoutBounds="20,0,.9,.9" AbsoluteLayout.LayoutFlags="WidthProportional,HeightProportional" />
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>
And the partial class:
namespace Gatemaster
{
public partial class Stats : ContentPage
{
public PlotModel Model {
get {
var model = new PlotModel { Title = "World population by continent" };
var ps = new PieSeries
{
StrokeThickness = .25,
InsideLabelPosition = .25,
AngleSpan = 360,
StartAngle = 0
};
// http://www.nationsonline.org/oneworld/world_population.htm
// http://en.wikipedia.org/wiki/Continent
ps.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = false });
ps.Slices.Add(new PieSlice("Americas", 929) { IsExploded = false });
ps.Slices.Add(new PieSlice("Asia", 4157));
ps.Slices.Add(new PieSlice("Europe", 739) { IsExploded = false });
ps.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = false });
model.Series.Add(ps);
return model;
}
private set {
}
}
public Stats()
{
InitializeComponent();
}
}
}
As per @Jason, I missed setting BindingContext. I find it incredibly odd that an error wasn't being thrown about a missing property...