Touch Events in .NET MAUI

Yusuf 791 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!

Developer technologies .NET .NET MAUI
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.