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 panel the focus shifts to the button rather than on the Textbox. The requirement states that a cursor should always appear in the text box to indicate the position where the next character will be inserted. Is there a way i can keep focus on the textbox while button is clicked.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
To set logical focus to an input control
To set keyboard focus to an input control
To know the difference between logical and keyboard focus
Input Overview - Focus on MSDN
this will focus on the textbox
Your problem can be solved by using a separate focus scope for your "keyboard". Just apply the following property to the control that contains all of your buttons and then they will be in a separate focus scope and will not have the focus set to them when clicked
I wanted to do the same thing, but nothing seemed to work for me. I really needed an answer that worked purely in XAML as I'm working with MVVM.
I finally found this example: http://spin.atomicobject.com/2013/03/06/xaml-wpf-textbox-focus/
and modified it to this:
In the 'Resources' section:
In my grid definition:
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.
I had to use this to get my desired result