Touch Events in .NET MAUI

Yusuf 691 Reputation points
2024-05-10T01:53:53.1+00:00

Hi
I'm working on a piano keyboard app in .NET MAUI, and I'm encountering an issue with implementing a specific feature. I want users to be able to slide their finger across the keys, triggering a note for each key they pass over. However, I'm only able to detect touch when the user taps on a key, not when they slide their finger across it. Previously, I used a this article for guidance while working on Xamarin, but it's not proving helpful now.
Silent Keyboard
And I used to get the following error:
System.InvalidOperationException: 'No service for type 'Microsoft.Maui.Controls.Hosting.EffectsFactory' has been registered.'
How can the issue be solved? Are there simpler techniques available in .NET MAUI?
Thanks!

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,961 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,946 Reputation points Microsoft Vendor
    2024-05-20T02:41:40.5366667+00:00

    Hello,

    I view the demo you provided, there are not TouchTrackingEffect.iOS/TouchEffect.cs and TouchTrackingEffect.Droid/TouchEffect.cs, please add these classes.

    (Note: Any ResolutionGroupNameAttribute and ExportEffectAttribute attributes should be removed from your effect classes.)

    At the same time, you didn't register the effect in MAUI, please see Reuse effects in .NET MAUI - .NET MAUI | Microsoft Learn

    (TouchTrackingEffect.UWP/TouchEffect.cs is missed as well, MAUI uses WinUI3 instead of UWP on Windows platform)

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments