开发者

Model responsibilities in MVVM

开发者 https://www.devze.com 2022-12-23 14:38 出处:网络
Is Model only Entity Data Mo开发者_如何学Cdel class of my database? Model as simple place where i have my data? Or I can input in Model something more?The model in MVVM is supposed to be the place for

Is Model only Entity Data Mo开发者_如何学Cdel class of my database? Model as simple place where i have my data? Or I can input in Model something more?


The model in MVVM is supposed to be the place for data-centric logic and the data, yes. It can be just the Entity Data Model, or you can add some more logic--that's up to you. The primary point is to seperate any presentation-specific logic from the model and put that in the viewmodel.

Hope that's clear enough


You can do whatever you like...

Typically, though, the "model" in MVVM is considered to be an "external" class (e.g. a generated class from LINQ-to-Entities, say) and so it usually doesn't have much logic.


The model is the core domain logic you are dealing with. It is everything not directly related to a UI view.

An easy way to think of it is the View and ViewModel combined represent what would be a "typical" UI layer without good separation. In MVVM, you split the logical aspects (the ViewModel) from the display logic (the View).

0

精彩评论

暂无评论...
验证码 换一张
取 消