Question

Hi I am trying to create a reusable XAML Window in a DLL.

I have placed in the Themes folder a new ResourceDictionary (I even merged it in the Generic.xaml), but when I try to use its styles in the window, I get an error message that the style doesn't exist:

<Window Style="{StaticResource ModalWindowStyle}" >
    <!-- I have also the following -->
    <Window.Resources>    
        <Style TargetType="Button" BasedOn="{StaticResource ButtonStyle}" />
    </Window.Resources>
</Window>

I get an exception that this styles don't exist, they are both declared in that ResourceDictionary which is in the Themes folder.

Was it helpful?

Solution

From this post:

... as long as Project B has a reference to Project A.

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Project A;component/YourSubFolder/YourResourceFile.xaml" />
</ResourceDictionary.MergedDictionaries>

Then you can just use the Resources defined in YourResourceFile.xaml.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top