maui: [regression/8.0.0] TapGestureRecognizers not working in maui embedded

Description

TapGestureRecognizer used to work in Xamarin.Forms just fine.

I migrated to .NET 8.0 and MAUI, TapGestureRecognizers kind of worked. If I used them on a Frame control, it didn’t fire, so I changed everything to use the Border control and that worked.

Now, I have migrated to .NET 8.0 and TapGestureRecognizers don’t seem to work at all.

I created a test app, where I added a Border with a Grid inside and a TapGestureRecognizer, the Tapped event seems to work in this case, but the Command does not.

In my main project, I am using Maui Embedded and it doesn’t work with the Tapped event nor the Command.

<Border BackgroundColor="{DynamicResource Accent}"
        MaximumWidthRequest="300"
        HeightRequest="40"
        Margin="20, 0, 20, 5"
        x:Name="LoginButton">

    <Border.StrokeShape>
        <RoundRectangle CornerRadius="4" />
    </Border.StrokeShape>

    <Border.GestureRecognizers>
        <TapGestureRecognizer Command="{Binding LoginButtonTappedCommand}" />
    </Border.GestureRecognizers>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Image Grid.Column="0"
            Source="fingerprint.png"
            HorizontalOptions="Start"
            VerticalOptions="Center"
            Margin="5,0,0,0"
            IsVisible="false"
            x:Name="FingerprintIcon" />

        <Label Grid.Column="1"
            Text="Log In"
            TextColor="White"
            VerticalTextAlignment="Center"
            Margin="20,0"
            x:Name="LoginButtonText" />

        <ActivityIndicator Grid.Column="2" 
            x:Name="LoginActivityIndicator"
            HorizontalOptions="End"
            Scale="0.7"
            Color="White"
            IsVisible="{Binding IsLoading}"
            IsRunning="{Binding IsLoading}" />

        <Image Grid.Column="3"
            Source="chevron_right.png"
            VerticalOptions="Fill"
            HorizontalOptions="End"
            Margin="0, 0, 5, 0">
            <Image.Behaviors>
                <behaviors:IconTintColorBehavior TintColor="White" />
            </Image.Behaviors>
        </Image>
    </Grid>
</Border>

Is there some documentation on what has changed? Or is this just a bug?

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.1.9171

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, Yes, this used to work in Xamarin.Forms

Last version that worked well

7.0.92

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

https://github.com/dotnet/maui/issues/17948#issuecomment-1828833433

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 4
  • Comments: 25 (15 by maintainers)

Most upvoted comments

https://github.com/ultimategrandson/MauiEmbeddedTapGestureBrokenRepro

I tried to create the simplest repro, run it on Android and try and click the black label, and it doesn’t work.

For me, its because I use Maui Embedded. Our app has been around since before Xamarin Forms was a thing, some parts of our App then used Xamarin Forms because it made dev faster. Now we’re struggling to have a stable version that uses Maui because not enough testing seems to be done in embedded scenarios.

It would be great to use Maui to replace all our other platform specific pages/forms. However, we need to have the embedded features stable first so we can reliable maintain what we have now before we can migrate to a purely Maui app.

Can you try the workarounds I have here?

Archive.zip

https://github.com/ultimategrandson/MauiEmbeddedTapGestureBrokenRepro

I tried to create the simplest repro, run it on Android and try and click the black label, and it doesn’t work.

For me, its because I use Maui Embedded. Our app has been around since before Xamarin Forms was a thing, some parts of our App then used Xamarin Forms because it made dev faster. Now we’re struggling to have a stable version that uses Maui because not enough testing seems to be done in embedded scenarios.

It would be great to use Maui to replace all our other platform specific pages/forms. However, we need to have the embedded features stable first so we can reliable maintain what we have now before we can migrate to a purely Maui app.

If someone checks it out, before creating a PR please also take a look at #16622 (containing a repro). I really don’t want to “hijack” this issue here but also don’t want mine getting closed again as “We recently fixed some TapGestures issues, please reopen if it still exist”.

@ultimategrandson I just added a navpage because @fedemkr was asking

You don’t have to add one

Okay, we got distracted by the static methods part, so I moved that to a new issue and hid the comments on this issue so we can stay focused on @ultimategrandson’s report. Thanks!

@ultimategrandson thanks for the repo, I am able to reproduce your issue. @PureWeen not sure how this relates to embedding, but might be the contexts not set up right.

Do we have an embedded sample? I know you were working on things, so checking to see if you had one? If not, we need to create one and make sure it gets added to the maui repo. I can do the last part.

@mattleibow I could not get your example to trigger the TapGestureRecognizer. Even if it did work, I need to use a TapGestureRecognizer in a list and pass in the item being tapped and my use case did not your example.

I created a repo at https://github.com/anotherlab/MauiTapGestureRecognizersNotWorking that shows code that will work with .NET 7, but not with .NET 8