How Do I Give a Textbox Focus in Silverlight?

前端 未结 15 1774
無奈伤痛
無奈伤痛 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:14

    None of the above answers worked for me directly, what i did is that I added this event in in the MainPage() constructor:

    this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    

    And handled it as follows:

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

    My Silverlight version is 4.

提交回复
热议问题