Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Advantages of Dependency Property </p> <p>As a matter of fact a Dependency Property have a lots of advantages over the normal CLR properties. </p> <ol> <li><strong>Property Value Inheritance :</strong> By Property Value Inheritance we mean that value of a Dependency property can be overridden in the hierarchy in such a way that the value with highest precedence will be set ultimately. </li> <li><strong>Data Validation :</strong> We can impose Data Validation to be triggered automatically whenever the property value is modified. </li> <li><strong>Participation in Animation :</strong> Dependency property can animate. WPF animation has lots of capabilities to change value at an interval. Defining a dependency property, you can eventually support Animation for that property. </li> <li><strong>Participation in Styles :</strong> Styles are elements that defines the control. We can use Style Setters on Dependency property. </li> <li><strong>Participation in Templates :</strong> Templates are elements that defines the overall structure of the element. By defining Dependency property, we can use it in templates. </li> <li><strong>DataBinding :</strong> As each of the Dependency property itself invokes <code>INotifyPropertyChanged</code> whenever the value of the property is modified, <code>DataBinding</code> is supported internally. To read more about <code>INotifyPropertyChanged</code>, please read. </li> <li><strong>CallBacks :</strong> You can have callbacks to a dependency property, so that whenever a property is changed, a callback is raised. </li> <li><strong>Resources:</strong> A Dependency property can take a Resource. So in XAML, you can define a Resource for the definition of a Dependency property. </li> <li><strong>Metadata overrides :</strong> You can define certain behavior of a dependency property using PropertyMetaData. Thus overriding a metadata form a derived property will not require you to redefine or reimplementing the whole property definition. </li> <li><strong>Designer Support :</strong> A dependency property gets support from Visual Studio Designer. You can see all the dependency properties of a control listed in the Property Window of the Designer. </li> </ol> <p>In these, some of the features are only supported by Dependency Property. <code>Animation</code>, <code>Styles</code>, <code>Templates</code>, Property value Inheritance etc could only be participated using Dependency property. If you use CLR property instead in such cases, the compiler will generate error. </p> <p>please go through these articles,</p> <p><a href="http://www.codeproject.com/KB/WPF/BeginWPF4.aspx#diff" rel="noreferrer">http://www.codeproject.com/KB/WPF/BeginWPF4.aspx#diff</a></p> <p>and <a href="http://www.dotnetfunda.com/articles/article961-wpf-tutorial--dependency-property-.aspx" rel="noreferrer">http://www.dotnetfunda.com/articles/article961-wpf-tutorial--dependency-property-.aspx</a></p> <p>and <a href="http://msdn.microsoft.com/en-us/library/cc221408(VS.95).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/cc221408(VS.95).aspx</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload