开发者

how can i define a Hotkey to edit the text in an AutoCompleteBox?

I'm using the WPF AutoCompleteBox control, i need to define a hotkey to begin the edition of its content immediatelly. I have this:

            if (Keyboard.IsKeyDown(Key.LeftAlt) && Keyboard.IsKeyDown(Key.F))
            autoCompleteBox2.Focus();

That code set the focus but the edition doesn't begin. I have to manually press the Left or Right key and then i could use it. I've search in his properties and in the web but I still don't found the a开发者_Python百科nswer.

That control is part of the WPF Toolkit. http://wpf.codeplex.com/releases/view/40535


I've had this issue in what I am coding right now, this is how I solved it, it is a little tricky:

To move the focus away:

 if (e.Key == Key.Enter)
            this.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));

autoCompleteBox2.Focus();

worked for me, you need to have set:

autoCompleteBox2.Focusable = true;

if it still doesn't work have you read this, it should help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜