Silverlight Preset focus (default focus)

Source: Internet
Author: User
Tags silverlight

recently in development Silverlight , there is a page that wants to set the focus on a TextBox allows the user to enter text directly.

Span style= "Font-family:verdana; Background-color:white ">silverlight To set the focus just set the" control " focus () method, but if you want to set the page one entry focus preset focus "

    • Set First Plugin Focus, and then set the focus of the control item control
    • Async at page initialization, placing the code of the preset focus in async

The code for the preset focus is as follows:

Using? System.Windows.Controls;
using? System.Windows.Browser;??? // Use HtmlPage to refer to this line first

namespace? SilverlightApplication1
{
???? public? partial? Class? MainPage?:? UserControl
???? {
???????? public? MainPage ()
???????? {
???????????? InitializeComponent ();
???????????? this. Loaded?+=? new? System.Windows.RoutedEventHandler (mainpage_loaded);
????????}

???????? void? Mainpage_loaded (objectsender,?) system.windows.routedeventargs?e)
???????? {
???????????? HtmlPage.Plugin.Focus ();? //to have this line in order to successfully set the control focus on one page
???????????? Textbox1.focus ();???????? // Then call to set the spotlight control Focus () method < Span style= "Font-family:courier New; Font-size:9pt ">
????????}
????}
}

Note: Use HtmlPage before you need to refer to System.Windows.Browser .

Silverlight Preset focus (default focus)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.