我试图将氧气图包含在Xamarin.Forms-Project
中这是我的Xaml.cs文件,我正在构建PlotModel。
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;
}
在Code中,只需将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?
非常感谢
答案 0 :(得分:0)
确保您拥有的OxyPlot版本与您拥有的表格版本兼容。
我不得不手动下载OxyPlot源并在过去更新Xamarin.Forms NuGet。