HOW TO GENERATE A TAPPED EVENT PROGRAMMATICALLY

Giorgio Sfiligoi 676 Reputation points
2024-10-27T08:29:15.8033333+00:00

Is it possible to "send" programmatically a Tapped event to a ContentPage?

i.e. simulate that the user tapped somewhere.

the platform is Android.

In my ContentPage I set HideSoftInputOnTapped="True"

There is an Entry:

        <Entry x:Name="entryField"
               ...
               IsReadOnly="True">
            <Entry.GestureRecognizers>
                <TapGestureRecognizer Tapped="OnFieldTapped" />
            </Entry.GestureRecognizers>
        </Entry>

It is read-only to prevent that tapping on it opens the soft keyboard.

Scenario:

  1. another field has its soft keyboard open;
  2. tapping anywhere will close it - this is the behavior that I want, BUT:
  3. tapping on the Entry above, the event is captured in my GestureRecognizer and does not close the existing soft keyboard.

The solution I envisage is: in my OnFieldTapped I forward the tapped event to the ContentPage or to any other element, to let the system close the software keyboard.

Developer technologies | .NET | .NET Multi-platform App UI

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

Your answer

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