Is it a good idea to aggregate ViewModels?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 15:15:17

问题


Is it a good or bad idea to have a ViewModel as a property of another ViewModel?

For example:

public sealed class ContentManagerViewModel : ViewModel
{
    public FindViewModel Find { get; set; }
}

回答1:


It's good, if it helps. But it all depends.

Usually I do have aggregated viewmodels. E.g. I may have a main window viewmodel. It may consist of different parts. Each part may be a separate view model...

If you could describe your particular architecture, we may give better advice :)..

Cheers, Anvaka




回答2:


Aggregate ViewModels you do only having relations between them. If thats the case you should better use the Mediator pattern with a concrete Messaging System.



来源:https://stackoverflow.com/questions/1928130/is-it-a-good-idea-to-aggregate-viewmodels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!