Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Have a look at <a href="http://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary.mergeddictionaries.aspx" rel="nofollow">ResourceDictionary.MergedDictionaries</a>. It allows you to combine resources defined in separate ResourceDictionaries.</p> <p>In your situation, Global.xaml, TabControl.xaml, and Button.xaml can each be a <a href="http://msdn.microsoft.com/en-us/library/ms589726.aspx" rel="nofollow">ResourceDictionary</a>, and master.xaml can merge them in its MergedDictionaries property:</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="Button.xaml" /&gt; &lt;ResourceDictionary Source="TabControl.xaml" /&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; </code></pre> <p>You also want styles to be able to reference styles from other resource dictionaries. You can achieve this in the same way:</p> <hr> <p>Button.xaml:</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="Colors.xaml" /&gt; &lt;!-- we want to use some colors from this resourcedictionary --&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;Style TargetType="Button"&gt; &lt;Setter Property="Foreground" Value="{StaticResource YourColor}"/&gt; &lt;/Style&gt; </code></pre> <p>You have to be careful though when merging that you don't introduce circular dependencies. If Colors.xaml merged Button.xaml in the example above, you would get a stackoverflowexception when you loaded either.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload