Implementing MVVM in WPF without using System.Windows.Input.ICommand

后端 未结 8 1685
醉梦人生
醉梦人生 2021-02-06 04:43

I\'m trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I\'d like to have the View part in a separate assembly (an EXE) from the Model and ViewM

8条回答
  •  自闭症患者
    2021-02-06 05:11

    You should be able to define a single WPF custom routed command in your wpf layer and a single command handler class. All your WPF classes can bind to this one command with appropriate parameters.

    The handler class can then translate the command to your own custom command interface that you define yourself in your ViewModel layer and is independent of WPF.

    The simplest example would be a wrapper to a void delegate with an Execute method.

    All you different GUI layers simply need to translate from their native command types to your custom command types in one location.

提交回复
热议问题