przemoo83
przemoo83

Reputation: 325

Styles as dll file?

I just downloaded a sample project from nukeation and I noticed something weird. There are no XAML files containing the styles but there is a reference to a particular resource:

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ReuxablesLegacy;component/mercury.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

But from what I see this ReuxablesLegacy is a .dll file not XAML. How do you create such styles? It seems quite convenient to keep them in one file like this.

Upvotes: 0

Views: 101

Answers (1)

Chiune Sugihara
Chiune Sugihara

Reputation: 1229

The xaml files are compiled as baml and embedded in their dll as resources assuming that they have the typical build action for xaml files of "Page". The standard stream that WPF will use in the dll is AssemblyName.g.resources where AssemblyName should be replaced by the name of your assembly. You can peak at this resource stream with a decompiler such as .net reflector.

This is typical behavior for any WPF application as long as you haven't changed the build action of xaml files from the default "Page" value. The URI for the resource dictionary that you are showing is just pointing to the embedded baml file in this other assembly that was created from "mercury.xaml".

For referencing resources from another assembly there is also the ComponentResourceKey mechanism but from what you are showing it looks like they are just dumping a bunch of resources in directly and aren't employing the component resource key type of approach.

Upvotes: 1

Related Questions