We help IT Professionals succeed at work.

How to focus in Silverlight control at start page (html or aspx) when using Google Chrome?

Last Modified: 2013-11-12
I need to get Google Chrome to focus my silverlight component. With firefox and IE my focus can be easily gained using the code shown at the end of question. The code is located at the MainPage which is the first page loaded at the startup.

I need to get focus in login dialog after first page is loaded. Then user writes his username and password etc. Without automatic focus user has to click login dialog, which is a nuisance.

With other browsers I can get focus to the plugin using method call:

Open in new window

In SL 2 javascript was used to gain focus. But that doesn't work with SL 4 to my knowledge.

I am using Silverlight 4 and C#.

Could you help me, please?
private void UserControl_Loaded(object sender, RoutedEventArgs e)
    // Use dispatcher to avoid silly SL 3 problem. Using SL 3
    // code had to call UpdateLayout method before focus.
    this.Dispatcher.BeginInvoke(() => myTextBox.Focus());
    // Get focus to SL component at web page

Open in new window

Watch Question

Senior Software Engineer
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.