11
有在NotificationObject
該方法的一個過載: -RaisePropertyChanged <T>如何找到屬性名稱?
protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression);
我們寫以下列方式中的屬性的setter:
RaisePropertyChanged(() => PropertyVariable);
它是如何工作的?它如何從這個Lambda表達式中找到屬性名稱?
這說明它如何做到:http://stackoverflow.com/questions/141370/inotifypropertychanged-property-name-hardcode- vs-reflection – Henrik 2012-04-20 09:15:35
在C#5中,你甚至不需要反射魔法:http://www.robfe.com/2011/09/raising-the-right-propertychanged-with-c-5s-caller-info -attributes/ – Vlad 2012-04-20 09:17:24
我忍不住在這裏提示resharper,當你嘗試去方法定義(F12)時,它很容易反編譯。您也可以像反射器一樣使用其他反編譯器。 – mkb 2015-09-21 12:18:37