Resources and Styles

WPF is able to store custom resources such as strings, images, styles, and custom data templates using a resource dictionary; by using this approach, you can store a custom style or an image in one place in the application that is visible and accessible from all the UI components.

The resources in WPF can be used, created, and modified by using either C# or the XAML markup; because the resource dictionary is nothing more than a XAML file, you can access this special container using the XAML markup. This choice is just a design choice and doesn't mean you should not access a resource using C# code.

The resources are an attached property of every XAML framework element, starting from the root element. Even if you can define ...

Get Applied WPF 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.