0
votes

I have a Windows 8.1 (WinRT) app and some UI class libraries and am trying to merge ResourceDictionaries into each other to split up my resources better. I have the following three projects with resources:

Framework.UI.Universal (Universal Class Library)

This is the Generic.xaml file contained in a Themes folder in this project:

<ResourceDictionary>
    <!-- Contains some resources used by Windows and Windows Phone -->
</ResourceDictionary>

Framework.UI.Windows (Windows Class Library)

This is another of the Generic.xaml file contained in a Themes folder in this project. As you can see I am merging the resource dictionary from the universal project, as well as adding other resources.

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="ms-appx:///Framework.UI.Universal/Themes/Generic.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    <!-- Contains Windows specific resources -->
</ResourceDictionary>

MyApp.Windows (Windows 8.1 App Project)

This is my Windows 8.1 App. I am merging the Windows specific resource dictionary into the App.xaml file, as well as adding app specific resources.

<Application x:Class="CurrencyConverter.Client.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:InfrastructureViews="using:Infrastructure.Client.Views"
             RequestedTheme="Light">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ms-appx:///Framework.UI.Windows/Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <!-- Contains Windows app specific resources -->
        </ResourceDictionary>
    </Application.Resources>
</Application>

In theory this should work but I get an exception on startup with the error message below:

cycle detected in merged resource dictionaries

1
Sounds like circular references exist, which is a no-no.Chris W.
But I'm not adding a circular reference at all as far as I can see.Muhammad Rehan Saeed
So you don't have two dictionaries pointed at each other and the likes?Chris W.
No, I have a chain of resources. A -> B -> C. Where A is the Universal resources, B is the Windows resources and C is the App.xaml.Muhammad Rehan Saeed

1 Answers

1
votes

Renaming the Generic.xaml in the Universal project to UniversalGeneric.xaml solved the problem. This seems to be a WinRT bug.