Open FroggieFrog opened 2 months ago
Why can't you just use the TouchGestureCompleted
event from the TouchBehavior
and not bother with a TapGestureRecognizer
?
TouchBehavior
has a Command property, but BindingContext is not setEventToCommandBehavior
to another BehaviorI agree with point 4 but I was just trying to find a simpler solution for you. Can you set the BindingContext
of the TouchBehavior
?
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.
Message = "Operation is not valid due to the current state of the object."
at Microsoft.Maui.Controls.Binding.
d27.MoveNext() at System.Threading.Tasks.Task.<>c. b 128_0(Object state) at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.b__0()
<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>
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 - https://github.com/CommunityToolkit/Maui/issues/1783
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
A
TapGestureRecognizer
is not triggered when used in combination with aTouchBehavior
and inside of aBorder
with aShadow
.Expected Behavior
The
TapGestureRecognizer
is triggeredSteps To Reproduce
Toast
when clicked on the second imageLink to public reproduction project repository
https://github.com/FroggieFrog/BugMauiShadowTouch
Environment
Anything else?