0
我可能会错过简单的东西,请耐心等待。 我有一个包含以下内容的视图模型:从Child ViewModels接收通知
public ObservableCollection<Person> PersonCollection
{
get { return personCollection; }
set
{
if (personCollection != value)
{
personCollection = value;
RaisePropertyChanged("PersonCollection");
}
}
}
然后在另一个视图模型我:
public ObservableCollection<Person> PersonCollection
{
get
{
PersonViewModel vm = (App.Current.Resources["Locator"] as ViewModelLocator).PersonViewModel;
return vm.PersonCollection;
}
}
public PersonViewModel PersonViewModel
{
get
{
return ((App.Current.Resources["Locator"] as ViewModelLocator).PersonViewModel)
}
}
在我的XAML,如果我绑定到PersonCollection
然后更新不上我的看法发生,但如果我绑定到PersonViewModel.PersonCollection
它。那么这是做到这一点的“正确”方式,还是有一种方法让视图使用第一种方法检测通知?
啊我明白你在说什么。我想这在你思考时很明显。因此,在ViewModel中使用实体的方式是根据我的第二种方法在父级内提供子ViewModel的属性,然后通过该方法进行绑定? – Firedragon