10.2. Resource Dictionaries

If you want to share resources between multiple projects, you can create a resource dictionary. A resource dictionary is simply a XAML document that does nothing but store the resources you want to use.

10.2.1. Creating a Resource Dictionary

Here's an example of a resource dictionary that has one resource:

<ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ImageBrush x:Key="TileBrush" TileMode="Tile"
    ViewportUnits="Absolute" Viewport="0 0 32 32"
    ImageSource="happyface.jpg" Opacity="0.3">
  </ImageBrush>
</ResourceDictionary>

When you add a resource dictionary to an application, make sure the Build Action is set to Page (as it ...

Get Pro WPF in C# 2010: Windows Presentation Foundation in .NET 4 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.