Cursor Focus on Textbox in WPF/C#

前端 未结 8 1064
星月不相逢
星月不相逢 2020-12-23 22:14

I am currently in the process of creating a Onscreen keyboard. I am handling the button click using routedcommands. The issue is that when i click on the button in keyboard

8条回答
  •  被撕碎了的回忆
    2020-12-23 23:02

    I like these do-my-homework-for-me questions; "the requirement states"...priceless. For those who find this via Google, the trick to progmatically moving the cursor in a WPF TextBox is to use the SelectioNStart property.

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        textBox.Focus();
        textBox.SelectionStart = textName.Text.Length;
    }
    

提交回复
热议问题