WPF/XAML: Moving resources from the app.xaml file and allowing global access all round

Okay, so I've created a few resource dictionaries in my application.

However, the app.xaml is getting really big so it's getting difficult to manage. I know how to create a new resource dictionary file. However, I'm struggling to find a way for the all of the resource dictionaries to access eachother's resources if I'm not placing them all in the same location.

Here's an example of some color resources I want to re-locate.

            <Color x:Key="ContentAreaColorLight">#686868</Color>
            <Color x:Key="ContentAreaColorDark">#1E1E1E</Color>

            <Color x:Key="DisabledControlLightColor">#FFE8EDF9</Color>
            <Color x:Key="DisabledControlDarkColor">#FFC5CBF9</Color>
            <Color x:Key="DisabledForegroundColor">#FF888888</Color>

Open in new window


Plus Styles ...

           <SolidColorBrush x:Key="ColourBackgroundWindowGeneral" Color="#333337" />
            <SolidColorBrush x:Key="ColourForegroundWindowGeneral" Color="#E6E6E6" />
            <SolidColorBrush x:Key="ColourGroupboxGeneral" Color="#569CD6" />
            <SolidColorBrush x:Key="ColourCheckboxGeneral" Color="#B99E65" />
            <SolidColorBrush x:Key="ColourButtonHoverGeneral" Color="#686868" />
            <SolidColorBrush x:Key="ColourButtonDisabledGeneral" Color="#686868" />
            <Style x:Key="StyleWindowGeneral" TargetType="Window">
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey=ColourForegroundWindowGeneral}" />
                <Setter Property="Background" Value="{DynamicResource ResourceKey=ColourBackgroundWindowGeneral}" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="WindowStyle" Value="None" />
                <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
                <Setter Property="AllowsTransparency" Value="True" />
                <Setter Property="ShowInTaskbar" Value="False" />
            </Style>

Open in new window


I imagine it's pretty simple but I don't seem to be able to find the answer. Maybe I'm using the wrong terminology?
Matt CartlidgeSenior Infrastructure EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
The concept here is to use Merged Resource Dictionaries. Create your separate resource dictionaries however makes logical sense.

Then, in app.xaml, merge them:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Colours.xaml" />
            <ResourceDictionary Source="Styles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Matt CartlidgeSenior Infrastructure EngineerAuthor Commented:
Works great, thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WPF

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.