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
Post a Comment