nNote If you??™re dealing with a control that you??™ve created, you can use the property callback mechanism
to react to property changes and even raise an event. Many common controls use this technique for properties
that correspond to user-supplied information. For example, the TextBox provides a TextChanged event
and the ScrollBar provides a ValueChanged event. A control can implement functionality like this using the
PropertyChangedCallback, but this functionality isn??™t exposed from dependency properties in a general way
for performance reasons.
The second feature that??™s key to the way dependency properties work is dynamic value
resolution. This means when you retrieve the value from a dependency property, WPF takes
several factors into consideration. You??™ve already seen this at work in the ScrollBar example,
where the Value property depends on both the value applied locally by code and the
CoerceValueCallback.
This behavior gives dependency properties their name??”in essence, a dependency property
depends on multiple property providers, each with its own level of precedence. When you
retrieve a value from a property value, the WPF property system goes through a series of steps
to arrive at the final value. First, it determines the base value for the property by considering
the following factors, arranged from lowest to highest precedence:
1.
Pages:
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305