oxyplot を Xamarin.Forms-Project に含めようとしています
これは、PlotModel を構築する Xaml.cs ファイルです。
private void GeneratePlot()
{
var Points = new List<DataPoint>
{
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<DataPoint>
{
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;
}
コードでは、OxyPlotModel _opy を StackLayout に入れるだけで問題なく動作します。しかし、次のように Xaml に追加する場合:
<oxy:PlotView Model="{Binding Model}" VerticalOptions="Center" HorizontalOptions="Center" />
次の例外が発生します。
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'.
XamlでOxyPlotを使用するために何ができるか知っている人はいますか?
どうもありがとうございました