Understanding how DependencyProperty works and is implemented

Silverlight / WPF DependencyProperty enables data binding and indicates when a property has changed by value, without implementing INotifyPropertyChanged. My question is how it works at a low level - how DependencyProperty or DependencyObject execute this change notification when neither DependencyObject, DependencyProperty nor DispatcherObject defines any events. Is this related to the DispatcherObject.Dispatcher property?

Dependency properties or the DependencyObject class are not natively supported by INotifyPropertyChanged for the purpose of creating change notifications for the value of the DependencyObject source property to bind operation data.

This excellent clarification was made verbatim:

http://msdn.microsoft.com/en-us/library/ms752914.aspx

http://msdn.microsoft.com/en-us/library/ms753358.aspx

+6
source share
2 answers

Dependency properties are tightly integrated with the internal binding system. Therefore, instead of β€œnotifying about a change in a property,” the code setting the dependency property can call directly to the binding system and report this to the updated one.

Similarly, things like inherited / attached properties can be updated for any descendant elements and / or layout / measure / arrangement can be updated. He can even talk about any triggers (in styles or ControlTemplates) for reevaluation.

The dispatcher is not actually connected, but can be used during the process.

In short, he baked it in WPF / Silverlight.

+4
source

Well, when you register DependencyProperty, you provide a callback to call when the value changes.

Here you have more detailed information. I don't think anything else is known about the internal components of WPF. Maybe I'm wrong.

+1
source

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


All Articles