How to fire a textbox command upon losing focus in WPF?

后端 未结 1 1174
北恋
北恋 2021-01-28 04:57

The following template works fine if the user presses Enter, although I want the command to fire when the TextBox loses focus as well. How can I do this?

1条回答
  •  清歌不尽
    2021-01-28 05:40

    If you don't use any MVVM framework you could use InvokeCommandAction from System.Windows.Interactivity to execute command when event is fired

    
        
            
                
            
        
    
    

    you'll need to add reference to System.Windows.Interactivity and add namespace in your XAML:

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

    0 讨论(0)
提交回复
热议问题