Arlo
Arlo

Reputation: 980

Uno Platform - Reference resource dictionary within Shared project

I'm building an Uno app and need to reference a Resource Dictionary defined and stored in the Shared Project.

The project is set up like so:

Project structure

And in MainPage.xaml, I'm using:

<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///LaunchShowcase.Shared/Themes/CenteredPivotHeadersStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Page.Resources>

This results in the error message Cannot locate resource from 'ms-appx:///LaunchShowcase.Shared/Themes/CenteredPivotHeadersStyle.xaml'

What's the proper way to reference this resource dictionary?

Upvotes: 2

Views: 391

Answers (1)

J&#233;r&#244;me Laban
J&#233;r&#244;me Laban

Reputation: 5282

The shared project is not a "real" project, as would a library. The resource dictionary file is behaving as if it were directly integrated in the head project, therefore the name LaunchShowcase.Shared does not exist.

Try using this instead:

<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///Themes/CenteredPivotHeadersStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Page.Resources>

Upvotes: 3

Related Questions