作者:小肥沙沙2006_759 | 来源:互联网 | 2023-10-11 17:53
IamwritingaWPFsampleapp,andinthatIwanttodisplaylistofitemsinview.ViewhasMainVie
I am writing a WPF sample app, and in that I want to display list of items in view. View has MainViewModel
which contains ObservableCollection
. Clearly ItemViewModel
is so specific that there's nothing to abstract from it.
我正在编写一个WPF示例应用程序,并且我希望在视图中显示项目列表。 View包含MainViewModel,其中包含ObservableCollection
。显然,ItemViewModel是如此具体,以至于没有任何东西可以从中抽象出来。
Question - When I build collection of these items in MainViewModel
, is it OK to instantiate ItemViewModel
s manually, or should it be delegated to DI container?
问题 - 当我在MainViewModel中构建这些项的集合时,可以手动实例化ItemViewModel,还是应该委托给DI容器?
I am familiar with MVVM (and DI too), so point here is not whether to have ItemViewModel
(I need it). But if DI still applies here, I seek clarifications.
我对MVVM(以及DI也是如此)很熟悉,所以这里指的不是是否有ItemViewModel(我需要它)。但如果DI仍适用于此,我会寻求澄清。
1 个解决方案