Setting the focus

Jun 9, 2012 at 6:10 PM

After calling for example Controller.Action("User", "Login"); is there a way to set the focus on the username textbox? I can't set focus even if I create a codebehind class, and in the OnLoaded event I force setting the focus on the username field. It seems the View simply doesn't own the focus...

Coordinator
Jun 13, 2012 at 5:05 AM

Hmmm... good question. Setting the focus programmatically either in a code behind file or even with a custom behavior should work. What theme are you using? (I assume we are talking about the WPF UI, right?).

This actually happens to be something we have on the list as a generic feature for one of our next releases where any object can get a View.HasInitialFocus="True" setting that moves the focus to that field. But that has not been released yet.

Coordinator
Jun 15, 2012 at 7:00 AM

Update: Check out this Quick Tip topic: http://codeframework.codeplex.com/wikipage?title=Default%20Focus%20in%20Views

This is a feature that is in the upcoming build which we hope to ship in the next few days.