Forum Libraries, Components, and Plugins

SkiaSharp touch event blocking Xamarin.Forms clicks

I have SkiaSharp overlayed overtop Xamarin.Forms with a full-screen AbsoluteLayout.

    <AbsoluteLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" Spacing="0">
            <Button Text="Click Me" Clicked="btnClicked" />
        <skia:SKCanvasView x:Name="canvasView" 
                           AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"
                           Touch="canvasView_Touch" EnableTouchEvents="True" />

Here is my code-behind:

private void btnClicked(object sender, EventArgs e) {
    //Do something

private void canvasView_Touch(object sender, SKTouchEventArgs e) {
    if (e.ActionType == SKTouchAction.Released) {
        //Do something
    e.Handled = true;

I have e.Handled = true because that gets me e.ActionType == SKTouchAction.Released and others, which I need, but it prevents the Xamarin.Forms button from being clicked, which I also need. If I comment that line out, Xamarin.Forms buttons work again, but all I get are SKTouchAction.Pressed. How can I get both the rich touch actions SkiaSharp offers while also passing the touch events through to Xamarin.Forms? Flipping the order in AbsoluteLayout (putting SkiaSharp behind Xamarin.Forms) doesn't help. Thanks!

Sign In or Register to comment.