TextBox Cursor is NOT blinking

与世无争的帅哥 提交于 2019-11-28 09:57:52

问题


I have a WPF datagrid (4.0) with a custom column (derived from DataGridTextColumn).

In GenerateEditingElement I create a custom textbox control (with an additional button) and like to set the cursor into it so that the user can directly start editing.

The closest I get is that the caret is shown but is not blinking and I need an additional click to start editing.

All other stuff (binding, ...) is working nicely

Any ideas?


回答1:


Since the caret is shown, but not blinking, then I am guessing your control has Logical Focus, but not Keyboard Focus.

How are you setting the control as Focused?

myControl.Focus(); will give the control logical focus, but it won't respond to keyboard events because it doesn't have Keyboard focus. To give an element KeyboardFocus, use

Keyboard.Focus(myControl);

This is because WPF allows you to define multiple Focus Scopes, and each scope can have it's own focused element, however only one control in the entire application can have Keyboard Focus



来源:https://stackoverflow.com/questions/8010272/textbox-cursor-is-not-blinking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!