Search code examples
c#xamlwindows-phone-8windows-runtime

WinRT Using a shared resources xaml file in Universal App


I created a Universal Windows App Store app in Visual Studio 2013. I created a ResourceDictionary file called AllButtonShapes.xaml. In the Shared portion of my app, the App.xaml file has this in it:

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

In the Windows portion of the app, this works just fine and my app is able to find the resources defined in AllButtonShapes.xaml. However, when I try to launch the Windows Phone portion of the app, those resources aren't found.

How do I get the Windows Phone portion of my Universal app to see the resources defined in my App resources?


Solution

  • Try using the absolute path

    <ResourceDictionary Source="/AllButtonShapes.xaml"/>
    

    Honestly, I couldn't reproduce this problem. You can try checking the dictionary's build action, it must be set to Page. Maybe there's a name conflict or something else. Can you share your project file?