积极答复者
Windows8 的反射

问题
-
我想利用反射获得一个类中某个属性的值,
System.Reflection.PropertyInfo property = InComboBox.SelectedItem.GetType().GetProperty(InComboBox.DisplayMemberPath); this.InHintTextBox.Text = property.GetValue(InComboBox.SelectedItem, null).ToString();
但是Type 中已经没有 GetProperty 这个接口函数了,请问在Windows8 中如何利用反射获得值呢?
答案
-
Hi,
WinRT中是有反射的,而且使用的.Net的方法,下面有一个例子你可以试试这个方法:
del = this.GetType().GetTypeInfo().GetDeclaredMethod("OnEventRaised").CreateDelegate(eventInfo.EventHandlerType, this);
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
用你的那中方式报错,不知道是不是命名空间引用错了还是怎么了,
我用的是
System.Reflection.PropertyInfo property=System.Reflection.IntrospectionExtensions.GetTypeInfo(InComboBox.SelectedItem.GetType()).GetDeclaredProperty(InComboBox.DisplayMemberPath);
- 已标记为答案 Aaron XueModerator 2012年12月7日 8:23
全部回复
-
Hi,
WinRT中是有反射的,而且使用的.Net的方法,下面有一个例子你可以试试这个方法:
del = this.GetType().GetTypeInfo().GetDeclaredMethod("OnEventRaised").CreateDelegate(eventInfo.EventHandlerType, this);
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已标记为答案 iWillen 2012年12月6日 3:28
- 取消答案标记 Aaron XueModerator 2012年12月7日 8:23
-
Hi,
WinRT中是有反射的,而且使用的.Net的方法,下面有一个例子你可以试试这个方法:
del = this.GetType().GetTypeInfo().GetDeclaredMethod("OnEventRaised").CreateDelegate(eventInfo.EventHandlerType, this);
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
用你的那中方式报错,不知道是不是命名空间引用错了还是怎么了,
我用的是
System.Reflection.PropertyInfo property=System.Reflection.IntrospectionExtensions.GetTypeInfo(InComboBox.SelectedItem.GetType()).GetDeclaredProperty(InComboBox.DisplayMemberPath);
- 已标记为答案 Aaron XueModerator 2012年12月7日 8:23