Use of Behavior in WPF MVVM?

前端 未结 3 1854
北荒
北荒 2020-12-15 11:03

I am new to WPF MVVM .. Anybody clear the usage of the Behaviors in MVVM application in WPF?. Why we should go for Behavior even we have Method action in WPF MVVM ?

3条回答
  •  鱼传尺愫
    2020-12-15 11:27

    In MVVM you may need to call methods from the View if your ViewModel exposes methods, not commands. Behaviors allow for this.

    You state "we have Method action in WPF MVVM", but as far as I know "method action" is not part of WPF. If you are using a helper MVVM library, it may provide "method action" that could encapsulate methods in commands. In such a case, behaviors are not required for the MVVM pattern using methods.

    Note, though, that behaviors have other uses outside of MVVM.

提交回复
热议问题