Can't set focus to a child of UserControl

后端 未结 18 584
耶瑟儿~
耶瑟儿~ 2020-12-04 21:55

I have a UserControl which contains a TextBox. When my main window loads I want to set the focus to this textbox so I added Focusable=\"True

18条回答
  •  萌比男神i
    2020-12-04 22:31

    I have user control - stack panel with two text boxes.The text boxes were added in contructor, not in the xaml. When i try to focus first text box, nothing happend. The siggestion with Loaded event fix my problem. Just called control.Focus() in Loaded event and everthing.

提交回复
热议问题