Beispiel #1
0
 void timer_Tick(object sender, EventArgs e)
 {
     if (SearchContentTextBox.Focus())
     {
         MessageBox.Show("文本框聚焦成功!");
     }
 } 
Beispiel #2
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //let browser focus to current html element 
            System.Windows.Browser.HtmlPage.Plugin.Focus();
            
            //SearchContentTextBox.Focus();
            SearchContentTextBox.Dispatcher.BeginInvoke(() => { SearchContentTextBox.Focus(); });

            //use multi-thread to test if textbox is focused
            //DispatcherTimer timer = new DispatcherTimer();
            //timer.Interval = TimeSpan.FromMilliseconds(5000);
            //timer.Tick += new EventHandler(timer_Tick);
            //timer.Start(); 
        }