views:

405

answers:

1

I have a little problem right now and I don't know how to fix it. I want to add two resources to a window. One is a XAML File style resource, the other a ValueConverter Class.

Both of them work if I use only one resource at a time:

 <Window.Resources>
    <ResourceDictionary Source="Resources\MyStyles.xaml" />
 <Window.Resources>

or

<Window.Resources>
    <local:MarginConverter x:Key="adjustMargin"/>
</Window.Resources>

But if I try something like this:

<Window.Resources>
    <local:MarginConverter x:Key="adjustMargin"/>
    <ResourceDictionary Source="Resources\MyStyles.xaml" />
</Window.Resources>

I get the message the resource is already been set and can not set twice.

I have no idea how to get this done. Is there something like a resource group?

+4  A: 
<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resources\MyStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>

        <local:MarginConverter x:Key="adjustMargin"/>
    </ResourceDictionary>
</Window.Resources>

HTH, Kent

Kent Boogaart
Thanks a lot. I tried many things but to put the Converter into the ResourceDictionary was not one of them.
Holli