One notable exception is if you??™re creating resources
that depend on Windows settings (such as system colors). In this situation, you need to use
dynamic resources if you want to be able to react to any change in the current color scheme.
(Or if you use static resources, you??™ll keep using the old color scheme until the user restarts the
application.) You??™ll learn more about how this works when you tackle system resources a bit
later in this chapter.
As a general guideline, only use dynamic properties when
??? Your resource has properties that depend on system settings (such as the current
Windows colors or fonts).
??? You plan to replace your resource objects programmatically (for example, to implement
some sort of dynamic skinning feature, as demonstrated in Chapter 15).
However, you shouldn??™t get overly ambitious with dynamic resources. The primary issue is
that changing a resource doesn??™t necessarily trigger a refresh in your user interface. (It does in
the brush example because of the way brush objects are constructed??”namely, they have this
notification support built in.) There are a host of occasions where you need to show dynamic
content in a control in a way that the control adjusts itself as the content changes, and for that
it makes much more sense to use data binding (Chapter 16).
Pages:
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613