Question

I have setup a property and implement INotifyPropertyChanged

like so...

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));
}

I used this exact setup on other classes but for some reason in the Notify method the PropertyChanged variable is coming back null.

In other classes when this works the PropertyChanged event is not null and evaluates to a delegate? What am I missing here?

I am calling the public accessor from inside the class would that make a difference?

Was it helpful?

Solution

Whether the delegate is null or not depends on whether anything has subscribed to the event.

OTHER TIPS

add this code

event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged {
 add { this.PropertyChanged += value; }
 remove { this.PropertyChanged -= value; }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top