Binding Commands to Events?

前端 未结 6 2114
清歌不尽
清歌不尽 2020-12-01 06:57

What\'s a good method to bind Commands to Events? In my WPF app, there are events that I\'d like to capture and process by my ViewModel but I\'m not sure how. Things like lo

6条回答
  •  感情败类
    2020-12-01 07:41

    In order to handle events, you must have some code that attaches itself to the event and executes your command in response. The final goal is to have in XAML:

      MouseMoveCommand="{Binding MyCommand}"
    

    In order to achieve this you need to define an attached property for each event that you want to handle. See this for an example and a framework for doing this.

提交回复
热议问题