关于这个特定问题有很多问题,但提议的解决方案都没有对我有用。我无法让OxyPlot出现在iOS或Android中。我按照设置说明在Xamarin Forms init之后添加了各种Init方法。到目前为止我尝试了什么:
我使用的是Xamarin Android版本25.4.0.2,Xamarin Forms 2.4.0.18342和OxyPlot版本1.0.0。
这是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>
分部课:
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();
}
}
}
答案 0 :(得分:0)
根据@Jason,我错过了设置BindingContext。我觉得奇怪的是,错误没有丢失属性......