Reputation: 11
NotifyOfPropertyChange<ObservableCollection<BaseMdmViewModelCollection>>(() => SubItemsViewModels);
Upvotes: 1
Views: 233
Reputation: 13
You have a method NotifyOfPropertyChange(Func func), where in your case T1 is BaseMdmViewModelCollection.
SubItemsViewModels is from type ObservableCollection
This is a way to pass any function that returns the collection instead of passing the collection directly.
Cheers,
Gilad
Upvotes: 0
Reputation: 17010
In simple terms: When there is a change in the observable collection, return the Sub items view model.
Upvotes: 3
Reputation: 108937
It's making a call to a generic function with signature
NotifyOfPropertyChange<T>(Func<BaseMdmViewModelCollection>)
() => SubItemsViewModels
is identical to
delegate { return SubItemsViewModels; }
In other words,
NotifyOfPropertyChange<ObservableCollection<BaseMdmViewModelCollection>>(() => SubItemsViewModels);
is the same as
NotifyOfPropertyChange<ObservableCollection<BaseMdmViewModelCollection>>(Foo);
where Foo would be
private BaseMdmViewModelCollection Foo()
{
return SubItemsViewModels;
}
Upvotes: 3
Reputation: 2305
I'd be willing to bet that your NotifyOfPropertyChange
method is using the Func
to simply get the name of the property that changed. This gives you compile-time safety of property changes, which is much more preferable than saying NotifyPropertyChange("SubItemsViewModels")
. This approach is used extensively in WPF and Silverlight data bindings, but is also a general purpose pattern that is useful in many scenarios.
Upvotes: 0