Accessing binary resources in code
Accessing a binary resource in XAML is pretty straightforward, but this works for standard resources such as images. Other types of resources may be used in code, and this requires a different approach.
Make sure Visual Studio is up and running.
How to do it...
We'll create an application that shows book information read programmatically from an XML file stored as a resource:
- Create a new WPF Application named
- Add the
books.xml(found in the downloadable source for this chapter) file as a resource (make sure Build Action is set to Resource). As an alternative, you can create the file yourself and type its contents as shown in the next step.
books.xmlfile looks something ...