WPF - Set Focus when a button is clicked - No Code Behind

前端 未结 7 1293
小蘑菇
小蘑菇 2020-11-29 03:53

Is there a way to set Focus from one control to another using WPF Triggers?

Like the following example:



        
7条回答
  •  一生所求
    2020-11-29 04:21

    Is this what you want?

        
        
        
    

    c#:

        public void MoveFocusOnClick(object sender, RoutedEventArgs e)
        {
            Keyboard.Focus(txtName); // Or your own logic
        }
    

提交回复
热议问题