Using binary resources inside a WPF application
Binary resources are chunks of bytes added to a project with Build Action
defined for it. Generally, these are images, logos, fonts, files, and so on, which are required by the application and are bundled with it.
In this recipe, we will learn how to use binary resources in a WPF application.
Getting ready
To get started, open your Visual Studio IDE and create a new project called CH07.BinaryResourceDemo
. Make sure you select the WPF app as the project template.
How to do it...
Follow these steps to add images as binary resources inside a WPF application and load them into the application window:
- Right-click on the project to add a new folder. Follow the context menu path
Add
|New Folder
. Rename the newly created folder asImages
:

- Now right-click on the
Images
folder to add a few images. From the context menu entry, selectAdd
|Existing Item...
and add two images of your choice. In this example, we have added two existing images,image1.png
and...