Sometimes binary resources are defined in one assembly (typically a class library), but are needed in another assembly (another class library or an executable). WPF provides a uniform and consistent way of accessing these resources using the pack URI scheme. Let's see how to do this.
We'll create two assemblies—one that holds resources, and another that needs to use those resources:
Create a new blank solution by selecting File | New Project from the main menu and then navigating to Other Project Types | Visual Studio Solutions. Name it
BinaryResourceAccess
:Right-click on the Solution node in Solution explorer, and select Add | New Project…:
Select a WPF User Control Library project and name it
CH02.ClassLibraryResources
:We're not going to actually use any user controls, but this is a simple way to create a class library with WPF references already included.
Delete the
UserControl1...