Fody PropertyChanged不会触发另一个属性

时间:2015-09-22 10:53:58

标签: c# fody-propertychanged

我正在开发一个WPF项目。为了防止大量的锅炉代码,我正在使用Fody PropertyChanged。这是我的问题的一小部分:

[ImplementPropertyChanged]
public class MyViewModel : MyViewModelBase
{
    public bool HasCardSet
    {
        get
        {
            return Person != null && Person.Card != null;
        }
    }

    public void SavePerson()
    {
        Person.Card = new Card();
    }
}

[ImplementPropertyChanged]
public class MyViewModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public Person Person { get; set; }
}

[ImplementPropertyChanged]
public class Person : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public Card Card { get; set; }
}

[ImplementPropertyChanged]
public class Card : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public string Name { get; set; }
    public ObservableCollection<SomeOtherClass> Items { get; set; }
}

当我致电SavePerson()时(在MyViewModel中),它不会触发HasCardSet属性。 我添加了PropertyChangedNotificationInterceptor,并看到该属性“卡”在目标“人物”上发生了变化。但是HasCardSet中的断点不会触发。

0 个答案:

没有答案