<p>Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring to the table is </p>

<ul>
<li>Support for Callbacks (Validation, Change, etc)  </li>
<li>Property inheritance</li>
<li>Attached properties  </li>
</ul>

<p>among others.</p>

<p>But my question here is why do they need to be declared as static in the containing class? The recommmended way is to then add instance 'wrapper' property for them. Why ?</p>

<p>edit:
@Matt, but doesn't that also mandate that the property value is also shared across instances - unless of course it is a derived value ?</p>

[{'answer_id': 36689, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 3, 'selected': True, 'text': "<p>I see 2 reasons behind that requirement:</p>\n\n<ol>\n<li>You can't register same DP twice. To comply with this constraint you should use static variable, it will be initialized only one time thus you will register DP one time only.</li>\n<li>DP should be registered before any class (which uses that DB) instance created</li>\n</ol>\n"}, {'answer_id': 36695, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 3, 'selected': False, 'text': "<p>I think the reason you need the static instance of a dependency property is really just because that's how they were designed. The static bit holds all the property metadata - its default value, its owner type (handy if it's an attached property) etc, its callback methods for when it changes - that sort of thing. Makes sense to store these things statically across all instances of the class rather than per-instance.</p>\n"}, {'answer_id': 36873, 'author': 'Anthony Conyers', 'author_id': 3864, 'author_profile': 'https://Stackoverflow.com/users/3864', 'pm_score': 3, 'selected': False, 'text': "<p>Dependency properties are static because of a key optimization in WPF:  Many of the controls in WPF have tens, if not hundreds of properties.  Most of the properties in these classes are set to their default value. If DP's were instance properties, memory would need to be allocated for every property in every object you create.  Since DP's are static, WPF is free to manage each property's memory usage more effectively.</p>\n\n<p>The reason why you should supply a default value for any DP you register is because WPF will take care not to allocate extra memory for your property when it's set to its default value, no matter how many objects containing that property you create.</p>\n"}]
['https://Stackoverflow.com/questions/36682', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1695/']