Search code examples
uwpuwp-xamlwinui

How to access a resource dictionary contained in a referenced UWP Class Library?


I'm playing around with the idea of implementing a component library for a UWP app.

One thing I'm struggling with is accessing resources from resource libraries in the component library from within the main application.

Here's the solution layout for my test application:

enter image description here

So MainPage.Xaml contains an instance of TemplatedControl and I want to give the style (TemplatedControlStyle) which is contained in the resource dictionary Dictionary1.

How would I go about doing it?

I've had a go with the examples from here ResourceDictionary in a separate assembly but that question was about WPF rather than UWP and doesn't seem to work


Solution

  • I am not sure which category of URI schemes applies to such case but the following pattern should work.

    <ResourceDictionary Source="ms-appx:///[library name]/Dictionary1.xaml"/>