Search code examples
resourceswindows-phonewindows-store-appswindows-phone-8.1resourcedictionary

Windows Phone, loading resources from directory


I've got the following folder structure in the project:

Style
    MainStyles.xaml
MainPage.xaml

Inside MainPage.xaml I try to load resources from MainStyles:

<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Style\MainStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Page.Resources>

However, I get the following error message:

WinRT information: Failed to assign to property '%0'. [Line: 13 Position: 37]

Additional information: The text associated with this error code could not be found.

Line 13 and position 37 is the exact place of Source=".... If I move resources to the same directory as MainPage and remove the directory, everything works.

By the way, Visual Studio designer does not complain about lacking resources and use them correctly.

What am I doing wrong?


Solution

  • Try using a forward slash when setting the Source of a ResourceDictionary.

    I.e. Style/MainStyles.xaml