views:

2308

answers:

2

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?

+5  A: 

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

Stu Mackellar
A: 

add this code

event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { this.PropertyChanged += value; } remove { this.PropertyChanged -= value; } }

sazzad