NotifyOfPropertyChange<ObservableCollection<BaseMdmViewModelCollection>>(() => SubItemsViewModels);
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;
}
简而言之:当可观察的集合发生变化时,返回Sub items视图模型。
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.