MVVM View event Viewmodel command binding

前端 未结 3 1577
终归单人心
终归单人心 2020-12-21 12:12

I\'m looking for a good (read: simple) example on how to implement event aggregators with Prism. I\'ve never used Prism and I\'m also quite new to MVVM itself.

I hav

3条回答
  •  自闭症患者
    2020-12-21 12:35

    I didn't know PRISM's EventAggregator allowed for event->command binding.

    Another option for you in this case is using a "behavior". Here's a decent overview Behaviors: http://wpftutorial.net/Behaviors.html. You can ignore the Blend part of the tutorial; the important part is that you have at least the Blend 3 SDK installed. Here's how I did this:

    public class ButtonDoubleClickCommandBehavior : Behavior

    You could add another dependency property to the behavior to bind a command parameter so you can execute the command with that parameter; I just used null in my example.

    And my XAML:

    
    

提交回复
热议问题