Home > Net >  Sharing ResourceDicrionary between two projects
Sharing ResourceDicrionary between two projects

Time:07-30

I've an UWP app with following structure:

MyAwesomeApp.sln
  Common.csproj
    Resources.xaml
  Main.csproj (startup project)
    MainPage.xaml
    MainPage.xaml.cs
    App.xaml
    App.xaml.cs
  OtherProjects...

Can I use Resources.xaml in App.xaml or MainPage.xaml and how?

CodePudding user response:

It depends on the project type of Common. If it's a "Class Library (Universal Windows)" or "Windows Runtime Component" project, then you could directly access the resource file like:

 <Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///Common/Dictionary1.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

If it isn't a "Class Library (Universal Windows)" or "Windows Runtime Component" project, then you can't do that.

  • Related