wpf - Set focus to another element with default button event? -


i have tried following:

<button isdefault="true" content="process test file"          focusmanager.focusedelement="{binding elementname=txtclientid}"          command="{binding processfilecommand, updatesourcetrigger=propertychanged}"> </button> 

i have button set default. so, when user hits enter key processes command, doesn't set focus asked. however, when clicked mouse set focus. i'm sure there's got easy way setting focus work default action too.

do focusing in button's click event. it'll called when press enter, too.

<button isdefault="true" content="process test file"          command="{binding processfilecommand, updatesourcetrigger=propertychanged}"         click="button_click"> </button> 

then, in code-behind:

private void button_click(object sender, routedeventargs e) {     keyboard.focus(txtclientid); } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -