Understanding dependency property system

235 Views Asked by At

Could someone help me to figure out with dependency property system in WPF?! I just wanted to do something like this:

Assume, class A have a property (DP) called "A_property". Another class B just represent some business logic and I wanted this class would be able to monitor "A_property". I mean that class B should subscribe class A's property. If someone so kind, please, provide me a sample how to do that using dependency property system?

P.S. It's clear to me how to solve the above problem using RoutedEvent, but it seems to me that DP system should simplify the solution.

Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

You can use DependencyPropertyDescriptor for this:

var descriptor = DependencyPropertyDescriptor.FromProperty(A.AProperty, typeof(A));
descriptor.AddValueChanged(...);