Setting the focus to a control in silverlight

I wasn’t able to set the focus to a control while loading a page in Silverlight. I had to search for a solution rather than finding the cause of this, since this was very important. Then, I found one. Here it is.

     this.Loaded += (sender, e) =>

            {

                Dispatcher.BeginInvoke(() =>

                {

                    this.Focus();

                    HtmlPage.Plugin.Focus();

                    UserNameText.Focus();

                });

            };

 

This can be written in the constructor of the XAML.CS

 

Happy Coding J

N.E.A.L

Comments