title: Howto: Applying a Style defined in generic.xaml to a UserControl? (WPF)
body: <p>I've created a style in generic.xaml that i want to use in my project on several UserControls. In the same way i have defined a style for a custom control and this one works so it seems generic.xaml is loaded, this is the defined style:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type UserControl}" x:Key="ServiceStyle" x:Name="ServiceStyle"&gt;
      &lt;Setter Property="Opacity" Value="0.5"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type UserControl}"&gt;
                  &lt;Border Name="border" CornerRadius="20"
                          Margin="10"
                          BorderThickness="5"
                          BorderBrush="Black"&gt;
                          &lt;ContentPresenter Content="{TemplateBinding Content}"
                                            Margin="{TemplateBinding Padding}"/&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>But now i want to use this style but i cannot get it to work. i've tryed adding it as a style parameter to a custom instance of UserControl in the following way:</p>
  
  <pre><code>&lt;UserControl
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:Netcarity"
      xmlns:CustomControls="clr-namespace:Netcarity.CustomControls"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="Portier_deur" x:Class="Netcarity.UserControlPortier"
      Height="600" Width="800" MouseDown="UserControl_MouseDown" Loaded="UserControl_Loaded" mc:Ignorable="d"
      Style="{StaticResource ServiceStyle}"&gt;
  </code></pre>
  
  <p>however this gives me a note that the resource ServiceStyle could not be found. When trying to run there is a runtime error on this.</p>
  
  <p>Thanks in advance.</p>