title: WPF (Bug) FocusVisualStyle doesn't work for Window with Template
body: <p>I have got the problem with <strong>FocusVisualStyle</strong>, I need to override <strong>TAB keyboard</strong> focus style, when i'm override <strong>Window.Template</strong> all controls styles <strong>FocusVisualStyle</strong> on the window stops working.</p>
  <p>The problem XAML (Tab style doesn't work):</p>
  <pre><code>&lt;Window
      x:Class=&quot;WpfApp1.MainWindow&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      Width=&quot;800&quot;
      Height=&quot;450&quot;&gt;
      &lt;Window.Style&gt;
          &lt;Style TargetType=&quot;Window&quot;&gt;
              &lt;Setter Property=&quot;Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType=&quot;{x:Type Window}&quot;&gt;
                          &lt;ContentPresenter HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot; /&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Window.Style&gt;
      &lt;Window.Resources&gt;
          &lt;Style x:Key=&quot;ButtonTabFocused&quot; TargetType=&quot;Control&quot;&gt;
              &lt;Setter Property=&quot;Control.Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate&gt;
                          &lt;Rectangle Margin=&quot;-3&quot; StrokeThickness=&quot;3&quot; Stroke=&quot;Red&quot; SnapsToDevicePixels=&quot;true&quot;/&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid Background=&quot;White&quot;&gt;
          &lt;Button
              Width=&quot;100&quot;
              Height=&quot;40&quot;
              Content=&quot;MyButton&quot;
              FocusVisualStyle=&quot;{StaticResource ButtonTabFocused}&quot; /&gt;
  
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xHS6w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xHS6w.png" alt="enter image description here" /></a></p>
  <p>Without <strong>Window.Style</strong> <strong>FocusVisualStyle</strong> works well (Tab style works):</p>
  <pre><code>&lt;Window
      x:Class=&quot;WpfApp1.MainWindow&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      Width=&quot;800&quot;
      Height=&quot;450&quot;&gt;
      &lt;Window.Resources&gt;
          &lt;Style x:Key=&quot;ButtonTabFocused&quot; TargetType=&quot;Control&quot;&gt;
              &lt;Setter Property=&quot;Control.Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate&gt;
                          &lt;Rectangle Margin=&quot;-3&quot; StrokeThickness=&quot;3&quot; Stroke=&quot;Red&quot; SnapsToDevicePixels=&quot;true&quot;/&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid Background=&quot;White&quot;&gt;
          &lt;Button
              Width=&quot;100&quot;
              Height=&quot;40&quot;
              Content=&quot;MyButton&quot;
              FocusVisualStyle=&quot;{StaticResource ButtonTabFocused}&quot; /&gt;
  
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/nlmDb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nlmDb.png" alt="enter image description here" /></a></p>
  <p>No msdn information founded. Could you please tell me any workarounds or am i missed something what's makes this behavior.</p>
  <p>My environments:</p>
  <ul>
  <li>.NET Framework 4.7.2 (same for older versions)</li>
  <li>Windows 10 19042.685</li>
  <li>Visual Studio 2019</li>
  </ul>
  <p>Thanks.</p>
  <p>UPDATE, working style below, thanks to arxont:</p>
  <pre><code>    &lt;Style TargetType=&quot;Window&quot;&gt;
          &lt;Setter Property=&quot;Template&quot;&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType=&quot;{x:Type Window}&quot;&gt;
                      &lt;Grid&gt;
                          &lt;AdornerDecorator&gt;
                              &lt;ContentPresenter HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot; /&gt;
                          &lt;/AdornerDecorator&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>