Set the focus on a textbox in xaml wpf

后端 未结 9 1042
走了就别回头了
走了就别回头了 2020-11-30 00:29

Despite some posts on this forum and others i cannot find something that tells me how to set the focus on a TextBox.

I have a userControl with many labe

9条回答
  •  情歌与酒
    2020-11-30 00:46

    From experimenting around, the xaml solution

    FocusManager.FocusedElement="{Binding ElementName=yourElement}"
    

    seems to work best when you place it in the highest element in the window hierarchy (usually Window, or the Grid you place everything else in)

提交回复
热议问题