Hide Soft Keyboard on start up in .net maui blazor android app

Vidula Sawant 1 Reputation point
2022-04-25T00:07:43.183+00:00

I need to hide soft keyboard at start-up screen. My screen holds a searchbox which has focus on it. Until user touches on the box, I need to hide the soft keyboard.
Essentially only want the soft keyboard to appear when user touches the searchbox (input type="search")
How do I achieve this for a .net maui blazor android app?

Developer technologies | .NET | Blazor
Developer technologies | .NET | .NET MAUI
{count} votes

2 answers

Sort by: Most helpful
  1. Rob Caplan - MSFT 6,037 Reputation points Microsoft Employee Moderator
    2022-04-26T22:54:13.137+00:00

    Android behavior is to show the keyboard when a text field gets focus. See Handling Keyboard Input in the Android docs:

    The Android system shows an on-screen keyboard—known as a soft input method—when a text field in your UI receives focus.

    If you don't want the keyboard to show up until the user touches the box then the natural way to do that is to make sure the focus starts elsewhere. How to do that will depend on your app layout and if your search-box is in a BlazorWebView or if it's in the surrounding Xaml. At the XAML level, you can call Focus on another control (a VisualElement), with the caveat that Focusing on a container may pass focus down to its first child that can take focus, which may end up back to your searchbox. Instead, you may want to set focus at the Blazor level on a control such as a button inside the web view.

    0 comments No comments

  2. Antonio Lopes 1 Reputation point
    2022-07-05T05:00:58.77+00:00

    While startup the page/application keep the Entry/Editor/TextBox "Disabled" (IsEnable="False"), after some milliseconds you can enable it to allow input. You can use a Timer object.
    You can put all in an MVVM controller using IsBusy/IsNotBusy pattern.
    When the page is processing turn IsBusy = true, and in IsEnable={Binding IsNotBusy}, do this, will dismiss the keyboard when the input control is not enabled (or processing).

    0 comments No comments

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.