Home > View Post

Xaml. Resource Dictionaries

Now that we've found out a little about resources and how useful they can be for storing things (and more importantly, reducing repetition in our Xaml) lets look at how we can reuse them across multiple Xaml files.

Enter the ResourceDictionary:

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <sys:DateTime x:Key="date1">20070711</sys:DateTime>
    <sys:DateTime x:Key="date2">20071225</sys:DateTime>

Wow! Now we can easily reuse our two dates (!? I know, I know) by referencing our resource dictionary in any other Xaml file:

            <ResourceDictionary Source="MyDictionary.xaml" />

Note that the dictionaries are merged. So if you have two things in with the same key, the last one wins.

Tags: Xaml

Josh Post By Josh Twist
12:01 AM
28 Feb 2007

» Next Post: Xaml. Embedding code
« Previous Post: Xaml. Using Resources

Comments are closed for this post.

© 2005 - 2022 Josh Twist - All Rights Reserved.