C#UWP禁用文本框或整个页面的电话键盘 [英] C# UWP disable phone keyboard for textbox or whole page

查看:108
本文介绍了C#UWP禁用文本框或整个页面的电话键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个文本框.我制作了自己的键盘,因此用户可以使用我的键盘及其etrxa按钮.但是,当我点击文本框以在其中键入内容时,电话仿真器上的电话键盘会弹出.我尝试了"PreventKeyboardDisplayOnProgrammaticFocus" 但是我读到它只是在程序本身选择文本框时将其禁用.

I have 2 TextBoxes. i made my own keyboard so the user uses my keyboard and its etrxa buttons. but when i tap on the textbox to type in it the phone keyboard on my phone emulator pops up. I tried the "PreventKeyboardDisplayOnProgrammaticFocus" but i read that it is only to disable it when the program itself chooses a textbox.

我了解到InputPane可以帮助我禁用它,但我不知道如何使用它,也找不到在其他任何地方使用它的方法.

I read that the InputPane can help me disable it but i can't understand how to use it and can't find a way to do it anywhere else.

有人可以帮我吗,我只是想禁用特定文本框或整个页面的键盘,所以当我点击文本框时,它不会弹出.

Can somebody help me i just want the keyboard disabled for specific textboxes or the whole page so when i tap on the textbox it won't pop up.

更新:好吧,经过很多考虑,我设法为我的应用程序做到了,我同时设置了两个文本框xaml

UPDATE: okay i managed after a lot of thought to do it for my app, i set both the textboxes xaml

    <TextBox IsReadOnly="True" />

因此,因为我不想对",所以现在不会为该文本框显示键盘,然后我的按钮取决于2个标记,这些标记指示文本框已聚焦,它们将在那里显示.但是,即使有人知道如何完全禁用键盘也可能会有所帮助,如果我在android上没有记错的话,会出现诸如禁用此文本框的键盘之类的事情.

so now the keyboard won't show up for that textbox since i "don't want to right" then my buttons depending on 2 flags that indicate wich TextBox is focused they will wright there. But still if someone knows how to disable the keyboard completely it could help, if i am not mistaken on android there is such a thing as disable keyboard for this textbox.

推荐答案

您可以使用TextBox.PreventKeyboardDisplayOnProgrammaticFocus属性,但还需要将Textbox的焦点更改为Programmatic.

You can use the TextBox.PreventKeyboardDisplayOnProgrammaticFocus property but you also need to change the focus of your Textbox to Programmatic.

一个简单的例子是:

<TextBox x:Name="myTextBox" PreventKeyboardDisplayOnProgrammaticFocus="True"/>

public MainPage()
{
    this.InitializeComponent();
    timer = new DispatcherTimer();
    timer.Interval = TimeSpan.FromMilliseconds(500);
    timer.Tick += delegate
    {
        try
        {
            myTextBox.Focus(FocusState.Programmatic);
            timer.Stop();
        }
        catch { }
    };
}

这篇关于C#UWP禁用文本框或整个页面的电话键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆