Linked Resource Dictionaries in Loose XAML

Something cool that I didn’t know “just worked” – linked resource dictionaries in Loose XAML!

In this sample:

  • dictionary.xaml contains a ResourceDictionary
  • page.xaml just links to dictionary.xaml.

See how it looks when you navigate to page.xaml. (And don’t forget to click on the fishies!)

Page.xaml:

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

   <Page.Resources>
       <ResourceDictionary Source="dictionary.xaml"/>
   </Page.Resources>

       <Button Style="{StaticResource BigFish}">
           <Button Style="{StaticResource SmallFish}"/>
       </Button>
</Page>

BTW, you might have seen these styles before… They come from the WPF Feature Montage originally given by Fil Fortes at Mix06 & updated by Rob Relyea for TechEd

1 comment

  1. Hello,

    Thanks for the tip. I’ve just one remark: it could be more complete if you tell how to do the same thing while the xaml is compiled into a separate dll.

Leave a Reply

Your email address will not be published. Required fields are marked *