When should I use FrameworkPropertyMetadata or UIPropertyMetadata over plain PropertyMetadata?

WpfAttached PropertiesAttachedbehaviors

Wpf Problem Overview


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?

Wpf Solutions


Solution 1 - Wpf

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRoger LipscombeView Question on Stackoverflow
Solution 1 - Wpfgp.View Answer on Stackoverflow