views:

219

answers:

1

I would like to refer to a MergedDictionary together with locally declared resources in my Windows.Resources. However, I'm getting this error:

"All objects added to an IDictionary must have a Key attribute or some other type of key associated with them."

Is it possible to mix local resources together with imported resources in the same Window.Resources?

The XAML is:

 <Window.Resources>
    <CollectionViewSource x:Key="cvsData" Source="{Binding Path=Data}">
        <CollectionViewSource.GroupDescriptions>
            <PropertyGroupDescription PropertyName="Country"/>
        </CollectionViewSource.GroupDescriptions>           
    </CollectionViewSource>

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary x:Name="images" Source="pack://application:,,,/CoreWpfControls;component/Images.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

Thanks Jeremy

+3  A: 

Yes, it's actually very simple. You just need to move the additional resources inside of the ResourceDictionary element.

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/CoreWpfControls;component/Images.xaml"/>
        </ResourceDictionary.MergedDictionaries>
        <CollectionViewSource x:Key="cvsData" Source="{Binding Path=Data}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Country"/>
            </CollectionViewSource.GroupDescriptions>           
        </CollectionViewSource>
    </ResourceDictionary>
</Window.Resources>
Josh Einstein
Duh - how simple is that?? I looked everywhere in the documentation/Google and couldn't find the answer. Thanks so much!!
Jeremy Holt