Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 926
JeeShen Lee Avatar asked Feb 04 '13 08:02

JeeShen Lee


People also ask

How do you reference a resource dictionary?

You can reference a resource throughout an app or from any XAML page within it. You can define your resources using a ResourceDictionary element from the Windows Runtime XAML. Then, you can reference your resources by using a StaticResource markup extension or ThemeResource markup extension.

What is resource dictionary?

A resource dictionary is a repository for XAML resources, such as styles, that your app uses. You define the resources in XAML and can then retrieve them in XAML using the {StaticResource} markup extension and {ThemeResource} markup extension s. You can also access resources with code, but that is less common.

What is Resource Dictionary in xamarin forms?

A ResourceDictionary is a repository for resources that are used by a Xamarin. Forms application. Typical resources that are stored in a ResourceDictionary include styles, control templates, data templates, colors, and converters.


2 Answers

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."

like image 143
JeeShen Lee Avatar answered Sep 30 '22 08:09

JeeShen Lee


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

like image 44
Sorskoot Avatar answered Sep 30 '22 09:09

Sorskoot