How Expression Blend add reference to external resource dictionary defined in third party library theme
Asked Answered
P

3

6

I'm trying to add reference to resource library defined in another project (e.g Elysium) and use it in expression blend.

Here's how i merge the resource dictionary in my App.Xaml file.

    <Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro.Resources;component/Icons.xaml" />
            <ResourceDictionary Source="pack://application:,,,/Telerik.Windows.Themes.Metro;component/Themes/System.Windows.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

But I can't seem to get any of the brushes resource defined in those libraries at Expression Blend 4. Any idea?

enter image description here

Persecute answered 4/2, 2013 at 8:7 Comment(2)
Did you ever find a solution to this ? I am faced with exactly the same problemCumulative
@DeanChalk yes, i posted my solution below but was not allowed to mark my answer as solution. Please try and mark as answer if you find it helpful. thanks.Persecute
P
5

Found my answer on Expression Blend Forum: http://social.msdn.microsoft.com/Forums/en/blend/thread/21bdc8a1-4a58-49f9-ae4d-c736b8fd673a

"Project > Link To Existing Item > (Navigate to the external Resource Dictionary, select it and click ok.) Rebuild."

Persecute answered 5/2, 2013 at 9:2 Comment(2)
What if the external resource is in a dll? I'm also using MahApps.Metro in my application and I'd like to be able to reference resources (mainly brushes) from the themes in my views using Blend to discover them for me.Commendatory
I just did this and there was a necessary additional step. After linking and rebuilding, follow Sorskoot's instructions below to link the view or control in your second project to the dictionaries you've just linked to the project. Only then can you select the shared resources as a "Local Resource" in the advanced options menu of your objects.Jazminejazz
S
1

I think the Source property is set incorrectly.

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary 
                   Source="/WpfControlLibrary1;component/BrushesInAssembly.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<Grid x:Name="LayoutRoot" Background="{DynamicResource RedBrush}"/>

What I did to come to this:

As a sample I created a new WPF project in Blend and added a control library. I referenced the assembly from the main project.

I added a resource dictionary with one brush, RedBrush.

project

Than I went to MainWindow.xaml and opened the Resources Panel. There I linked the dictionary.

resource pane

After linking it shows up in list of resources.

RedBrush

Stratfordonavon answered 4/2, 2013 at 12:43 Comment(1)
I tried what you suggested on an external library (project library that is under different namespace, something like a 3rd party user control). I couldn't see the file listed as shown in your example.Persecute
M
0

Hope you found a solution already, but if not I use this link here as a constant reference.

It's does the following: shows how to link ResourceLibraries in external Resource projects, how to name styles and organize them so that anyone on a team knows what's going on, etc. So simple, so great.

Hope it helps someone.

Modesta answered 11/4, 2013 at 16:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.