views:

705

answers:

1

When looking at sample attached properties and behaviors, I've seen a mishmash of uses of FrameworkPropertyMetadata, UIPropertyMetadata and PropertyMetadata. Since they all form an inheritance hierarchy, how do I choose which one to use?

+3  A: 

These classes are to report some behavior aspects of a dependency property.

Check the different classes for the options they provide.

For example,

if you just want to back a property by dp and provide a default value, use PropertyMetaData,

if you want to specify animation behavior, use UIPropertyMetaData,

but if some property affects wpf framework level stuffs eg element layout, parent layout or databinding, use FrameworkPropertyMetaData.

Details you can check on msdn http://msdn.microsoft.com/en-us/library/ms751554.aspx

gp
The real question is, why does the propdp snippet use UIPropertyMetadata, especially since there are no PropertyMetadata subclasses in Silverlight? It drives me nuts.
Grank
That's because same snippets are shared between WPF and Silverlight.You can try different snippets for silverlight from this link:http://blog.nerdplusart.com/archives/silverlight-code-snippets
gp
+1 Editing the snippets is so simple as well.
Avatar