title: Apply Textbox Style to Control
body: <p>I'm New to Wpf and trying to learn using web based tutorials</p>
  
  <p>I have created a Control (Class) Name <strong>MyTextBox</strong> which is inherited from <strong>TextBox</strong></p>
  
  <pre><code>Public Class MyTextBox
         Inherits TextBox
  .
  .
  End Class
  </code></pre>
  
  <p>I have created a <strong>Style</strong> for <strong>TextBox</strong> in <strong>Application.xaml</strong></p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;Style TargetType="TextBox"&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsFocused" Value="True"&gt;
                  &lt;Setter Property="Background" Value="Yellow"/&gt;
                  &lt;Setter Property="BorderBrush" Value="Gray"/&gt;
                  &lt;Setter Property="BorderThickness" Value="2"/&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p>When I Add MyTextBox to my Form and run it, the above style applies to TextBox Control but there is No Effect on MyTextBox Control</p>
  
  <p>Please Tell my How to Solve This</p>
  
  <p>Amit Saraf</p>