Maui禁用控件焦点

Maui禁用控件焦点

  1. 安卓
    在CreateMauiApp()方法添加如下代码。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    EntryHandler.Mapper.AppendToMapping("NoKeyboardEntry", (handler, entry) =>
                {
    #if ANDROID
                    // 隐藏软键盘
                    handler.PlatformView.ShowSoftInputOnFocus = false;
                    handler.PlatformView.ImeOptions = Android.Views.InputMethods.ImeAction.ImeNull;
                    handler.PlatformView.InputType = Android.Text.InputTypes.Null;
                    handler.PlatformView.PrivateImeOptions = "";
    #endif
                });
                ButtonHandler.Mapper.AppendToMapping("Project.Buttons.NoSystemFocus", (handler, view) =>
                {
    #if ANDROID
                    if (view is Button)
                    {
                        handler.PlatformView.FocusableInTouchMode = false;
                        handler.PlatformView.Focusable = false;
                    }
    #endif
                });
    
  2. Windows

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy