Depending on how you do your references/includes etc., you might want to use a different class name if you wanted to add the code in this post to your application or library.
* The way the GetProperties is written, it doesn't exclude the attached properties. Semantically, attached properties are dependency properties (at least the WPF ones are, by implementation). But syntactically, the usages are different in either XAML or code. So depending on what you're doing with the information, you might want to tweak GetProperties to exclude the APs that GetAttachedProperties returns.
* The code will end up revealing a basic truth about attached properties in WPF: all attached properties exist on all DependencyObjects, so it doesn't particularly matter which Object element you pass in to GetAttachedProperties so long as it's a DO subtype. Result is you'll get dozens of APs listed on any possible DO, and barring inclusion of DLLs other than the WPF project defaults it'll always be the same list.
List DependencyProperties?
Jehan Badshah
That's handy code, but I'll offer some caveats for it.
* The typename that was chosen for the illustrated class has potential for name collision with another class DependencyPropertyHelper that is already defined in System.Windows: http://msdn2.microsoft.com/en-us/library/system.windows.dependencypropertyhelper.aspx
Depending on how you do your references/includes etc., you might want to use a different class name if you wanted to add the code in this post to your application or library.
* The way the GetProperties is written, it doesn't exclude the attached properties. Semantically, attached properties are dependency properties (at least the WPF ones are, by implementation). But syntactically, the usages are different in either XAML or code. So depending on what you're doing with the information, you might want to tweak GetProperties to exclude the APs that GetAttachedProperties returns.
* The code will end up revealing a basic truth about attached properties in WPF: all attached properties exist on all DependencyObjects, so it doesn't particularly matter which Object element you pass in to GetAttachedProperties so long as it's a DO subtype. Result is you'll get dozens of APs listed on any possible DO, and barring inclusion of DLLs other than the WPF project defaults it'll always be the same list.
mbakhodir
Brandon Hawkins
{{{{attachedProperties.Add(dpd.DependencyProperty);}}}{{{properties.Add(dpd.DependencyProperty);}}}}Disclaimer: The original author of the above code is Douglas Stockwell.
Sheva