1

I'm trying to learn more about WPF. I ran through an online tutorial that created a button and then created a template to be applied to additional buttons. The problem is this template is in the Window.xaml and I can only access the template from within that application. How do I make the template more globablly available? I'm thinking of some way to reference the xaml like you can reference an assembly from a different project or solution.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233

1 Answers1

1

You can use "resource dictionaries" which you reference in your App.xaml like this (Expression Blend does it automatically):

<Application.Resources>
    <!-- Resources scoped at the Application level should be defined here. -->
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ResourceDictionary1.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

How to reference a resource from another assembly, use pack URI syntax. This link covers it as well.

Community
  • 1
  • 1
Sergey Aldoukhov
  • 22,316
  • 18
  • 72
  • 99