Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Problem creating Custom Renderer

$
0
0

Good Morning,

I have a problem and I don't know how to solve it. I am working with Custom Renderers in a Xamarin Form Project with the target to modify the behavior of a ScrollView:

public class ScrollViewCustomRenderer : ScrollViewCustom
{
float StartX, StartY;
int IsHorizontal = -1;

    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e )
    {
        base.OnElementChanged(e);
        if (((Xamarin.Forms.ScrollView)e.NewElement).Orientation == ScrollOrientation.Horizontal) IsHorizontal = 1;

    }

    public override bool DispatchTouchEvent(MotionEvent e)
    {

        switch (e.Action)
        {
            case MotionEventActions.Down:
                StartX = e.RawX;
                StartY = e.RawY;
                this.Parent.RequestDisallowInterceptTouchEvent(true);
                break;
            case MotionEventActions.Move:
                if (IsHorizontal * Math.Abs(StartX - e.RawX) < IsHorizontal * Math.Abs(StartY - e.RawY))
                    this.Parent.RequestDisallowInterceptTouchEvent(false);
                break;
            case MotionEventActions.Up:
                this.Parent.RequestDisallowInterceptTouchEvent(false);
                break;
        }

        return base.DispatchTouchEvent(e);
    }
}

The problems are:
1.OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.ScrollView>)': no suitable method found to override.
2. Error 39 'Xamarin.Forms.Element' does not contain a definition for 'RequestDisallowInterceptTouchEvent' and no extension method 'RequestDisallowInterceptTouchEvent' accepting a first argument of type 'Xamarin.Forms.Element' could be found (are you missing a using directive or an assembly reference?)

I have installed the last Xamarin.Forms references.

Many thanks,
Regards


Viewing all articles
Browse latest Browse all 58056

Trending Articles