For Windows 8 / Windows Phone 8, most of this Reflection feature has been ported to the new TypeInfo class. You can find more information in this MSDN document . For information, including runtime properties (including those that are inherited, for example), you can also use the new RuntimeReflectionExtensions class (where filtering can be done simply through LINQ).
Although this is C # code (my apologies :)), here is something pretty equivalent using this new functionality:
public class TestClass { public string Name { get; set; } public object GetPropValue(string propertyName) { var propInfo = RuntimeReflectionExtensions.GetRuntimeProperties(this.GetType()).Where(pi => pi.Name == propertyName).First(); return propInfo.GetValue(this); } }
This code is even simpler if you only care about the properties declared in the class itself:
public class TestClass { public string Name { get; set; } public object GetPropValue(string propertyName) { var propInfo = this.GetType().GetTypeInfo().GetDeclaredProperty(propertyName); return propInfo.GetValue(this); } }
source share