Windows phone 7 从子视图模型接收通知

Windows phone 7 从子视图模型接收通知,windows-phone-7,mvvm-light,Windows Phone 7,Mvvm Light,我可能错过了一些简单的事情,所以请容忍我。 我有一个ViewModel,其中包含以下内容: public ObservableCollection<Person> PersonCollection { get { return personCollection; } set { if (personCollection != value) { personCollection = value;

我可能错过了一些简单的事情,所以请容忍我。 我有一个ViewModel,其中包含以下内容:

public ObservableCollection<Person> PersonCollection
{
    get { return personCollection; }
    set
    {
        if (personCollection != value)
        {
            personCollection = value;
            RaisePropertyChanged("PersonCollection");
        }
    }
}
public observeablecollection PersonCollection
{
获取{return personCollection;}
设置
{
if(personCollection!=值)
{
personCollection=值;
RaisePropertyChanged(“PersonCollection”);
}
}
}
在另一个ViewModel中,我有:

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)
    }
}
public observeablecollection PersonCollection
{
得到
{
PersonViewModel vm=(App.Current.Resources[“Locator”]作为ViewModelLocator);
返回vm.PersonCollection;
}
}
公共PersonViewModel PersonViewModel
{
得到
{
返回((App.Current.Resources[“Locator”]作为ViewModelLocator.PersonViewModel)
}
}

在我的XAML中,如果绑定到
PersonCollection
,则更新不会在我的视图上发生,但如果绑定到
PersonViewModel.PersonCollection
,则更新会发生。那么,这是一种“正确”的方法,还是视图可以使用第一种方法检测通知?

将绑定更改为
{binding PersonViewModel.PersonCollection}


您包装的
PersonCollection
属性没有更改通知,因此视图不知道该属性已更改(它当然无法知道它最初来自
PersonViewModel
,以便从中获取更改通知)

啊,我明白您的意思。我想当你想起来的时候,这是很明显的。因此,在ViewModel中使用实体的方法是,按照我的第二种方法,在父视图中提供子ViewModel的属性,然后可以通过该属性进行绑定?