79381437

Date: 2025-01-23 14:21:51
Score: 2
Natty:
Report link

Tried to find workaround and couldn't find any. The only way I discover is to use the same touch-behavior for clicks and rely on "CurrentInteractionStatus", which will be "Completed" after longtap trigger.

<Grid.Behaviors>
        <toolkit:TouchBehavior LongPressCompleted="LongPress_Handler" TouchGestureCompleted="Tap_Handler" LongPressDuration="750"/>
</Grid.Behaviors>

.

private void LongPress_Handler(object sender, CommunityToolkit.Maui.Core.LongPressCompletedEventArgs e)
{
    Console.WriteLine("Long Tap!");
}

private void Tap_Handler(object sender, CommunityToolkit.Maui.Core.TouchGestureCompletedEventArgs e)
{
    var stackItem = (View)sender;
    var touch = (CommunityToolkit.Maui.Behaviors.TouchBehavior)stackItem.Behaviors[0];
    if (touch.CurrentInteractionStatus == CommunityToolkit.Maui.Core.TouchInteractionStatus.Started)
    {
        Console.WriteLine("Normal tap!");
    }
}

If you find more reliable ways, please share.

Reasons:
  • RegEx Blacklisted phrase (2.5): please share
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Serg Tomcat