28 January, 2010
4 Comments
0 categories
If you want to set the focus on a textbox in Microsoft Silverlight, use the Loaded event and the System.Windows.Browser.HtmlPage.Plugin.Focus() prior to calling Control.Focus()
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace Ada.Tts.Toggle.Silverlight { public partial class MainPage : UserControl { /// <summary> /// Event fires on page load /// /// Set focus to search box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserControl_Loaded(object sender, RoutedEventArgs e) { System.Windows.Browser.HtmlPage.Plugin.Focus(); this.searchTextBox.Focus(); } /// <summary> /// Consturctor /// </summary> public MainPage() { InitializeComponent(); } } }
Tags: Silverlight
Thanks, worked well π
Thanks for the tip. π It worked.
Thanks it works well
Does Not worked in Firefox.. Worked well in IE..
Please advise..