How to define the usercontrols in mvvm pattern?

前端 未结 2 1225

I using from mvvm in my application. I want know how to define my user control in mvvm pattern.

Must I define it by using from mvvm, or I can define it generally?

2条回答
  •  一向
    一向 (楼主)
    2021-01-23 23:43

    I think that depends on the user control. The user control can be just a view, in which case you would compose a larger control or page which has this user control as part of the whole. The larger control or page would provide the view and the view model parts for this view.

    Or you could create a self contained user control which has all of mvvm and use events to interact with the larger user control that it is a part of.

    I suspect you'll get better reuse and modularisation with the second approach.

    In short: it depends.

提交回复
热议问题