How Do I Give a Textbox Focus in Silverlight?

前端 未结 15 1804
無奈伤痛
無奈伤痛 2020-12-01 07:49

In my Silverlight application, I can\'t seem to bring focus to a TextBox control. On the recommendation of various posts, I\'ve set the IsTabStop property to True and I\'m

15条回答
  •  不知归路
    2020-12-01 08:05

    I found this on silverlight.net, and was able to get it to work for me by adding a call to System.Windows.Browser.HtmlPage.Plugin.Focus() prior to calling RegularTextBox.Focus():

       private void UserControl_Loaded(object sender, RoutedEventArgs e)
       {        
          System.Windows.Browser.HtmlPage.Plugin.Focus();
          RegularTextBox.Focus();
       }
    

提交回复
热议问题