[Silverlight getting started series] focus of childwindow (the child form automatically sets focus for the Control)

Source: Internet
Author: User

Last time I talked about "how to set textbox focus in viewmodel". Some children's shoes reported that focus does not work in the childwindow subform. I tested it specially today. This problem exists. There is only one way to reload the onopened event of childwindow. The loading execution sequence of childwindow is:Initialized-Loaded-Opened(Including animation execution), so you only need to reload it in *. XAML. CS of your childwindow.

Then use the article "how to set textbox focus in viewmodel"ArticleIn the viewmodel, set to whom to focus. AboveCodeIt is my test code. The logic is: if it is a new user, focus on the user name input box. If it is an old user (remember the user name after the last login), the user name is automatically loaded, focus on the password input box. This logic is bound to the interface in viewmodel. If your logic is not as complex as mine, then TXT. Focus ().

(Note: I also tried to addTabindex= "1", 2, 3... Method. Of course, you still need to add it so that you can switch the focus on the tab .)

 

In short, using the mvvm mode for Silverlight development will encounter many similar problems, which are much more complicated than codebehind. The children's shoes should pay attention to cultivating their own problem-solving capabilities.

Related Article

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.