Strange. I just updated to XF 2.2 now that both OxyPlot and DevExpress supports it. I ran into a new issue on Android.
My app needs to be able to tap on an OxyPlot and get plot objects that were tapped. Since this isn't builtin, I extended PlotView like this:
public class TapPlotView : PlotView
{
public static BindableProperty DrillDownCommandProperty = BindableProperty.Create<TapPlotView, ICommand>(x => x.TapCommand,
null,
BindingMode.OneWay
);
public ICommand TapCommand {
get { return (ICommand)GetValue(DrillDownCommandProperty); }
set { SetValue(DrillDownCommandProperty, value); }
}
public void OnItemTapped(IEnumerable<HitTestResult> results)
{
if (TapCommand != null)
TapCommand.Execute (results);
}
}
I then implemented Renderers for both iOS and Android. iOS renderer adds a TapGestureRecognizer and works fine. However, my Android renderer:
public class TapPlotViewRenderer : PlotViewRenderer
{
private const int HIT_TOLERANCE = 15;
protected override void OnElementChanged (ElementChangedEventArgs<PlotView> e)
{
base.OnElementChanged (e);
if (Control != null) {
Control.Touch += delegate(object sender, TouchEventArgs tea) {
//Don't steal touch event which prevents pan/zoom
tea.Handled = false;
double scale = OxyPlot.Xamarin.Android.PlotView.Scale;
if(tea.Event.Action != MotionEventActions.Down)
return;
IEnumerable<HitTestResult> results = Control.Model.HitTest(new HitTestArguments(new ScreenPoint(tea.Event.GetX() / scale,tea.Event.GetY() / scale),HIT_TOLERANCE));
((TapPlotView)Element).OnItemTapped(results);
};
}
}
}
is failing with XF2.2 complaining about missing constructor (IntPtr,JniHandleOwnership) in PlotView. My google searches says this means something else is bad. Strange that this worked fine on Android for XF2.1.
Any ideas?