WPF ControlTemplates Exchange

I am trying to learn more about WPF. I checked an online tutorial that created a button and then created a template to apply to additional buttons. The problem is that this template is in Window.xaml and I can only access the template from this application. How do I make the pattern more globablly accessible? I am thinking of some way to reference the xaml, how you can reference an assembly from another project or solution.

0


a source to share


1 answer


You can use the "resource dictionaries" you reference in your App.xaml like this (Expression Blend does this 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>

      



To reference a resource from another assembly, use the package URI syntax. This link also covers.

+1


a source







All Articles