Prev | Current Page 612 | Next

Matthew MacDonald

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


One reason to use resource dictionaries is to define one or more reusable application
???skins??? that you can apply to your controls. (You??™ll learn how to develop this technique in
Chapter 15.) Another reason is to store content that needs to be localized (such as error message
strings).
CHAPTER 11 n RESOURCES 347
Sharing Resources Between Assemblies
If you want to share a resource dictionary between multiple applications, you could copy and
distribute the XAML file that contains the resource dictionary. This is the simplest approach,
but it doesn??™t give you any version control. A more structured approach is to compile your
resource dictionary in a separate class library assembly and distribute that component
instead.
When sharing a compiled assembly with one or more resource dictionaries, there??™s
another challenge to face??”namely, you need a way to extract the resource you want and use it
in your application. There are two approaches you can take. The most straightforward solution
is to use code that creates the appropriate ResourceDictionary object. For example, if you
have a resource dictionary in a class library assembly named ReusableDictionary.xaml, you
could use the following code to create it manually:
Dim resourceDictionary As New ResourceDictionary()
resourceDictionary.


Pages:
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624