什么时候应该使用 FrameworkPropertyMetadata 或 UIPropertyMetadata 而不是普通的 PropertyMetadata?

当看到样品附加属性和行为,我已经看到了一个混合使用的 FrameworkPropertyMetadataUIPropertyMetadataPropertyMetadata。由于它们都形成了一个继承层次结构,我如何选择使用哪一个呢?

23871 次浏览

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