【发布时间】:2015-01-12 10:13:22
【问题描述】:
如何在不共享视图模型的情况下获取用户控件的多个实例?每个用户控件(以及视图模型)都应该是它自己的一个实例。
我已经阅读了这个问题的解决方案:MVVMLight UserControl View Model-Create new Instance of User control for each view 但我无法让它工作!
我有一个列表视图和一个选项卡控件。当我单击列表视图的一个项目时,必须创建一个新选项卡,其中包含来自所选列表项的信息的用户控件作为内容。 The problem is that when selecting multiple items all the items contain the information from the last selected item.
这是我的视图模型定位器:
public DossierDetailViewModel DossierDetail
{
get
{
return new DossierDetailViewModel();
}
}
我这样称呼新的用户控件:
DossierDetailViewModel newDossier = new DossierDetailViewModel();
newDossier.TabName = SelectedDossier.Omschrijving;
this.OpenDossiers.Add(newDossier);
Messenger.Default.Send<DTO.Dossier.Dossier>(SelectedDossier, "SetDossier");
编辑: 没有人可以帮助我或将我引向正确的方向吗? :(
【问题讨论】:
标签: wpf mvvm-light