- Change notification
Dependency properties have a built-in change notification mechanism. By registering a callback in the property metadata you get notified, when the value of the property has been changed. This is also used by the databinding. - Value inheritance
When you access a dependency property the value is resolved by using a value resolution strategy. If no local value is set, the dependency property navigates up the logical tree until it finds a value. When you set the FontSize on the root element it applies to all textblocks below except you override the value.
- Reduced memory footprint
It's a huge dissipation to store a field for each property when you think that over 90% of the properties of a UI control typically stay at its initial values. Dependency properties solve these problems by only store modified properties in the instance. The default values are stored once within the dependency property.
Here is a very good article for DependancyProperty.
http://wpftutorial.net/DependencyProperties.html
http://wpftutorial.net/DependencyProperties.html
DependencyProperty.Register
DependencyProperty.RegisterReadOnly
DependencyProperty.RegisterAttched
No comments:
Post a Comment