在WP中点击控件时不要隐藏软键盘

Đra*_*nus 2 c# button cursor windows-phone-8 windows-phone-8.1

我在Windows Phone 8.1 Store App项目中使用了这段代码(不是Silverlight):

private void CursorRightButton_Click(object sender, RoutedEventArgs e)
    {
        if (string.IsNullOrWhiteSpace(QueryTextBox.Text)) return;
        QueryTextBox.Focus(FocusState.Keyboard); //also i tried FocusState.Pointer
        QueryTextBox.Select((TextBox.SelectionStart + 1) % (TextBox.Text.Length + 1), 0);
    }
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我想以编程方式将光标移动到文本右侧,问题是它隐藏了软键盘,然后在点击按钮后再次显示它.我需要在点击此按钮时打开键盘.

我试图修改发送方和TextBox对象的Focus()方法,但我找不到任何可能的解决方案.

所以问题是,在敲击控件时,如何强制键盘不松动焦点/不隐藏?

Đra*_*nus 5

我发现Sajeetharans帮助我需要将控件上的IsTabStop值设置为false.然后键盘会留在那里.我在我的页面的构造函数中这样做了

public MainPage()
{
    InitializeComponent();
    CursorLeftButton.IsTabStop = false;
    CursorRightButton.IsTabStop = false;
}
Run Code Online (Sandbox Code Playgroud)

和我的按钮方法

private void CursorRightButton_Click(object sender, RoutedEventArgs e)
{
    if (string.IsNullOrWhiteSpace(TextBox.Text)) return;
    TextBox.Select((TextBox.SelectionStart + 1) % (TextBox.Text.Length + 1), 0);
}
Run Code Online (Sandbox Code Playgroud)