WPF实现INotifyPropertyChanged

ctr*_*yan 2 data-binding wpf inotifypropertychanged

我已经设置了一个属性并实现了INotifyPropertyChanged

像这样......

public event PropertyChangedEventHandler PropertyChanged;

public FlowProcess LastSelectedFlowProcess
{
    get { return _lastSelectedFlowProcess; }
    set
    {
        _lastSelectedFlowProcess = value;
        Notify("LastSelectedFlowProcess");
        UpdateFlows();
    }
}

private void Notify(string propName)
{
    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
Run Code Online (Sandbox Code Playgroud)

我在其他类上使用了这个确切的设置,但由于某些原因,在Notify方法中,PropertyChanged变量返回null.

在其他类中,当这个工作时,PropertyChanged事件不为null并且计算为委托?我在这里错过了什么?

我在课堂上调用公共访问器会有所作为吗?

Stu*_*lar 10

委托是否为null取决于是否有任何订阅该事件.