Setting the focus to a control at the time of load in silverlight

I was not able to set the focus to a control when a silvelright application loads. I tried direct .Focus() in the constructor, and in the Loaded event, but failed to meet the objective. Then after googling for sometime, I found a resolution to the problem. It was written in the Loaded event, but a different approch.


this.Loaded += (sender, e) =>
            {
                Dispatcher.BeginInvoke(() =>
                {
                    UserNameTextBox.Focus();
                });
            };



Comments