简体   繁体   中英

Shared library not seeing resource dictionary

I have two wpf solutions that use the same class library (one I have written). The library references sytles (as static resources) that are in a resource dictionary of the main project. In one of those solutions, the library finds these static resources in the resource dictionary but in the other project the static resources are not resolved. In both cases the Resource dictionary is declared in the App.Xaml of the main application as follows:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary>
                <local:AppBootstrapper x:Key="bootstrapper" />
            </ResourceDictionary>
            <ResourceDictionary Source="StoryMakerStyle.xaml" />
            <ResourceDictionary Source="Resources\GlassButton.xaml"/>
            <ResourceDictionary Source="Resources\Slider.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Where StoryMakerStyle.xaml is the name of the resource dictionary in one app. It is called FlashcardsStyle.xaml in the other. The other 2 ResourceDictionary references are the same in both solutions.

Any suggestions as to why references to the resource dictionary are resolved in one solution but not the other? Thanks in advance

I'm assuming that this is a solution of 2 project. You need to specify which project when referencing the ResourceDictionaries like so:

<ResourceDictionary Source="/ProjectNamespace;Resources/GlassButton.xaml"/>
<ResourceDictionary Source="/ProjectNamespace;Resources\Slider.xaml" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM