How does the Silverlight / WPF runtime know how to set the dependency property?

So, I think I understand what a dependency property is and why we need them are properties managed by the Silverlight / WPF libraries, so the runtime can have some control over how they are installed, allowing them to do such things as providing animation priority over other types of requests for properties and other excellent functions.

My question is how does this structure know how to do this? If dependency properties are always accessible through their recipients / setters on their parent objects (which are transferred to GetValue() and SetValue() ), then how can the dependency repository * know who makes the request to determine its priority?

Sorry if this is a very simple / obvious question.

* Is there a name for a container that manages dependency properties? I think of the DP registry, given that we have to register them?

+4
source share
1 answer

Yes, there is a registry, but all of it is hidden. And No, dependency properties are not set at all through Getter and Setter, and DependencyObject has methods called GetValue and SetValue, where you actually pass a handle to your dependency property. Suppose your DP has a registry, and it has a dictionary and processes your DP (the DP object you receive after registration) is the key.

Thus, the registry knows when and what to change, and what needs to be updated and to whom notifications should be sent.

You can use the reflector to learn .NET inside, you get the idea that each DP needs to be registered by calling DependencyProperty.Register, then you can use it.

+2
source

Source: https://habr.com/ru/post/1345810/


All Articles