Set the focus on a textbox in xaml wpf

后端 未结 9 1063
走了就别回头了
走了就别回头了 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 01:04

    You can use the FocusManager.FocusedElement attached property for this purpose. Here's a piece of code that set the focus to TxtB by default.

    
        
        
    
    

    You can also use TxtB.Focus() in your code-behind if you don't want to do this in XAML.

提交回复
热议问题