Command for WPF TextBox that fires up when we hit Enter Key

前端 未结 5 2088
太阳男子
太阳男子 2020-12-04 17:31

It is very easy to bind Buttons in WPF apps to Commands in a VIEWMODEL class. I\'d like to achieve a similar binding for a TextB

5条回答
  •  独厮守ぢ
    2020-12-04 17:44

    Aryan, not every WPF object supports commanding. So if you wan't to do that you'll need either to call your view model from your code behind (a little coupled) or use some MVVM Messaging implementation to decouple that. See MVVM Light Messaging toolkit for an example. Or simple use triggers like this:

    
        
            
                
            
        
    
    

提交回复
热议问题