views:

284

answers:

2

I have a ClassA with an ObservableCollection Property, that implements the INotifyPropertyChanged interface

on my window codebehind I have declared a ClassA variable, and initialize it in the Main() method.

i'd expect that variable.PropertyChanged would have a WPF event wired to it, but apparently the PropertyChanged event remains null

+2  A: 

WPF will subscribe to the PropertyChanged event when you bind to your object. This is the core way that databinding works.

It actually does this via the PropertyChangedEventManager using the WeakEvent pattern in WPF.

Reed Copsey
+1  A: 

I'm not sure if this exactly answers your question, but I had similar experiences, and blogged about it here.

Essentially, make sure the DataContext is not null when the binding occurs, such that PropertyChanged events can get back to the UI...

IanR