views:

721

answers:

1

I'm binding to a method using an ObjectDataProvider. The class which exposes this method contains an ObservableCollection of type T:INofifyChanged. My problem is that because the methods return value is dependent upon the value of it's ObservableCollection, i need the binding to be updated when the ObservableCollection changes in any way.

In short, the return value of the method is dependent on other factors and i want this method binding to refresh when it's dependencies change.

How can i let the bound control know when the methods return value will be different?

+3  A: 

The ObservableCollection class exposes the CollectionChanged event which you could hook into.

You would possibly be better off using a ViewModel and handling the update via this though. Take a look at the MVVM pattern.

Pete OHanlon
I hope that is better than the bogus ItemDeleted eventargs for a BindingList :)
leppie
Okay, so if i handle the collectionchanged event, how do i let the consumer of the method binding know it needs to refresh? I don't think i can use the PropertyChanged event. Is there any equivalent MethodChanged or similar?
Stimul8d
Okay, i clearly needed a to refactor my solution and your answer is pretty close to how it ended up so kudos to you.
Stimul8d