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.