Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set the focus to a usercontrol's textbox when the user control is added to a wpf window.

I have tried the below sample.

<stackpanel orientation="Vertical" focusmanager.focusedelement="{Binding ElementName=txt1}">
Posted

WPF focusing is a pretty advanced topic. Please start here: http://msdn.microsoft.com/en-us/library/aa969768%28v=vs.110%29.aspx[^].

In most cases, you would need to set the logical focus. This is how: http://msdn.microsoft.com/en-us/library/system.windows.input.focusmanager.setfocusedelement(v=vs.110).aspx[^].

To set initial keyboard focus you can use http://msdn.microsoft.com/en-us/library/system.web.ui.control.focus%28v=vs.110%29.aspx[^].

To understand what to use when, please see the very first link above.

—SA
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900