What is the easiest way to share resources between UserControls in a WPF User Control library? -


there wpf user control library , 2 (or more) user controls in it. need use same style in both user controls. how can share style? example:

this style:

<style x:key="customlabelstyle" targettype="label">     ... </style> 

user control a:

<usercontrol x:class="edu.wpf.example.usercontrola"    ...xmlns stuff... >    <grid>       ... xaml markup...       <label style="{staticresource customlabelstyle}"/>    </grid> </usercontrol> 

usercontrol b:

 <usercontrol x:class="edu.wpf.example.usercontrolb"    ...xmlns stuff... >    <grid>       ... xaml markup...       <label style="{staticresource customlabelstyle}"/>    </grid> </usercontrol> 

so how can share style between user controls in library without involving of application app.xaml resource dictionary?

update

i can add themes\generic.xaml library , define style there. in case have use componentresourcekey key of style. right? it's long , not handy expression...

you can define shared resources in separate resourcedictionary, merge them usercontrol's resources using mergeddictionaries.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -