Thursday, January 15, 2009

Silverlight Tip: Give Your Silverlight App Focus

I am working on a Silverlight application that starts off with a login page. Typically, users do not like to use the mouse when they get to a login page. They expect to go to the page, type their user name, tab, type their password, click return and they should be logged in. In order to get this type of behavior in a Silverlight application, you need to set the tab order of your fields, set the focus to the username textbox and also set the focus to your Silverlight app (remember... this is content inside of an aspx page.. or an htm page). To give the Silverlight content focus, simply make this call:


Then, give the username textbox focus and you should be set to go. One other thing... if you want users to be able to hit the return key immediately after typing their password, you will have to check for the return key in the text changed event handler of the password textbox. If the enter key is detected, then you can attempt to login at that time. If you do not do this, you will force your users to tab to the login button and then hit return. This just saves them a few clicks.

No comments:

Post a Comment