Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] TapGestureRecognizer not triggered when in combination with TouchBehavior and Border.Shadow #2165

Open
2 tasks done
FroggieFrog opened this issue Sep 3, 2024 · 5 comments
Labels
bug Something isn't working unverified

Comments

@FroggieFrog
Copy link

FroggieFrog commented Sep 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

A TapGestureRecognizer is not triggered when used in combination with a TouchBehavior and inside of a Border with a Shadow.

Expected Behavior

The TapGestureRecognizer is triggered

Steps To Reproduce

  1. run the app from the repo in Android 14
  2. click on the images
  3. see that there is no Toast when clicked on the second image

Link to public reproduction project repository

https://github.com/FroggieFrog/BugMauiShadowTouch

Environment

- .NET MAUI CommunityToolkit: 9.0.3
- OS: Android 14
- .NET MAUI: 8.0.82

Anything else?

maui_bug

@FroggieFrog FroggieFrog added bug Something isn't working unverified labels Sep 3, 2024
@bijington
Copy link
Contributor

Why can't you just use the TouchGestureCompleted event from the TouchBehavior and not bother with a TapGestureRecognizer?

@FroggieFrog
Copy link
Author

  1. I need to execute a Command -> TouchBehavior has a Command property, but BindingContext is not set
  2. I can't attach a EventToCommandBehavior to another Behavior
  3. I want to avoid code behind
  4. I can't think of any reason why my wanted behavior should not be possible

@bijington
Copy link
Contributor

I agree with point 4 but I was just trying to find a simpler solution for you. Can you set the BindingContext of the TouchBehavior?

@FroggieFrog
Copy link
Author

Unfortunately no.
As soon as I add either BindingContext or Command to the toolkit:TouchBehavior, the app crashes. (screenshot and stacktrace are from WinUI, but same behavior on Android)
I don't even have to add the Border to make it crash.

Stacktrace

Message = "Operation is not valid due to the current state of the object."

at Microsoft.Maui.Controls.Binding.d__27.MoveNext()
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.b__0()

grafik

my code

 <Border
     Grid.RowSpan="2"
     Grid.Column="1"
     Margin="0,40,0,0"
     HorizontalOptions="Center">
     <Border.Behaviors>
         <toolkit:TouchBehavior
             BindingContext="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:MyViewModel}}}"
             Command="{Binding MyCommand}"
             HoveredOpacity="0.8"
             HoveredScale="0.9"
             PressedOpacity="0.6"
             PressedScale="0.8" />
     </Border.Behaviors>
     <!--<Border.GestureRecognizers>
         <TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:MyViewModel}}, Path=MyCommand}" />
     </Border.GestureRecognizers>-->

     <Image Source="{Binding MyModel, Converter={StaticResource myConverter}}" />
 </Border>

@hansmbakker
Copy link

As soon as I add either BindingContext or Command to the toolkit:TouchBehavior, the app crashes. (screenshot and stacktrace are from WinUI, but same behavior on Android)
I don't even have to add the Border to make it crash.

Stacktrace
Message = "Operation is not valid due to the current state of the object."

@FroggieFrog that one could be this issue - #1783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unverified
Projects
None yet
Development

No branches or pull requests

3 participants