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

Viewed 13431

There are a WPF User Control library and two (or more) User Controls in it. I need to use the same style in both user controls. How can I share this style? For example:

This is the style:

<Style x:Key="customLabelStyle" TargetType="Label">
    ...
</Style>

User control A:

<UserControl x:Class="Edu.Wpf.Example.UserControlA"
   ...xmlns stuff... >
   <Grid>
      ... some xaml markup...
      <Label Style="{StaticResource customLabelStyle}"/>
   </Grid>
</UserControl>

UserControl B:

 <UserControl x:Class="Edu.Wpf.Example.UserControlB"
   ...xmlns stuff... >
   <Grid>
      ... some another xaml markup...
      <Label Style="{StaticResource customLabelStyle}"/>
   </Grid>
</UserControl>

So how can I share this style between user controls in the library without involving of the application app.xaml resource dictionary?

UPDATE

I can add Themes\Generic.xaml into my library and define the style there. But in this case I have to use ComponentResourceKey as the key of the style. Right? It's long and not very handy expression...

3 Answers
Related