Prev | Current Page 287 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

)
This behavior is due to WPF??™s property resolution system, which stores the exact local
value you??™ve set internally but evaluates what the property should be (using coercion and a
few other considerations) when you read the property. More information about this system is
in the section ???How WPF Uses Dependency Properties??? later in this chapter.
nNote Long-time Windows Forms programmers may remember the ISupportInitialize interface, which
was used to solve similar problems in property initialization by wrapping a series of property changes into
a batch process. Although you can use ISupportInitialize with WPF (and the XAML parser respects it), few
of the WPF elements use this technique. Instead, it??™s encouraged to resolve these problems using value
coercion. There are a number of reasons that coercion is preferred. For example, coercion solves other
problems that can occur when an invalid value is applied through a data binding or animation, unlike the
ISupportInitialize interface.
Shared Dependency Properties
Some classes share the same dependency property, even though they have separate class
hierarchies. For example, both TextBlock.FontFamily and Control.FontFamily point to the
same shared dependency property, which is actually defined in the TextElement class and
TextElement.


Pages:
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299