我试图将 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'.
有谁知道我可以做些什么来将 OxyPlot 与 Xaml 一起使用?
非常感谢