Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I most easily determine whether a property is a dependency property?

I recently had an issue with databinding to the Visibility property of a DataGridTextColumn. The confusion arose because this property is a dependecy property in WPF but not in Silverlight.

I don't think that the MSDN documentation makes this very clear. The following is the only related text for WPF.

"For information about what can influence the value, see DependencyProperty."

http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcolumn.visibility(v=VS.100).aspx

like image 490
Scott Munro Avatar asked Nov 25 '25 23:11

Scott Munro


2 Answers

Dependency properties have a corresponding static field on the class they are defined in. Have a look at the fields section of the DataGridTextColumn class.

like image 72
Jens Avatar answered Nov 28 '25 00:11

Jens


In most cases you can detect whether a property Foo is a DP by checking if there is a static field named FooProperty of type DependencyProperty. However, this is only a convention. There is no guarantee that all dependency properties will follow this pattern.

like image 20
Thomas Levesque Avatar answered Nov 28 '25 00:11

Thomas Levesque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!