net maui hide keyboard when flyoutpage is shown

95 views Asked by At

When an entry has focus and the keyboard is shown, when i then open the flyoutpage by clicking the burger icon on the top left, the keyboard remains open.

I would like the keyboard to close when i open the flyoutpage.

1

There are 1 answers

0
Alexandar May - MSFT On

I would like the keyboard to close when i open the flyoutpage.

Suppose the Entry exists in the FlyoutPageItem: Page1 as below:

<CollectionView x:Name="collectionView"
                        x:FieldModifier="public"
                        SelectionMode="Single"
                        SelectedItem="null">
      <CollectionView.ItemsSource>
            <x:Array Type="{x:Type local:FlyoutPageItem}">

                <local:FlyoutPageItem Title="Page1"
                                      IconSource="hamburger_icon.png"
                                      TargetType="{x:Type local:Page1}" />

You can add HideSoftInputOnTapped in Page 1 in XAML like below which indicates whether tapping anywhere on the page will cause the soft input keyboard to hide if it's visible. Before clicking the burger icon on the top left, you can tap anywhere on the Page 1 which will hide the keyboard per your requirement. Lastly, this is a .NET 8 newly added feature so make sure your app is .NET 8 based.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiAppFlyoutNavigation.Page1"
             
             HideSoftInputOnTapped="True"
             Title="Page1 ">