PropertyHelper class is a reflection-based helper class to get or set properties on classes. This class is used by Catel as a fall-back mechanism to use reflection in case cached expression trees are not supported.
For better performance, use the
Setting or getting properties of objects
In lots of cases, you need to possibility to set or get properties of an object via reflection. This behavior is implemented in the
PropertyHelper class. Below are a few examples.
Check if a property is available on an object
Getting a property value
string firstName; PropertyHelper.TryGetValue(person, "FirstName", out firstName);
Setting a property value
PropertyHelper.SetValue(person, "FirstName", "Geert");
PropertyHelper.TrySetValue(person, "FirstName", "Geert");
We would like to thank the following contributors:
Want to contribute to the documentation? We have a guide for that!
Have a question about Catel? Use StackOverflow with the Catel tag!