title: WPF Window Chrome styling
body: <p>I'm using <a href="https://msdn.microsoft.com/en-us/library/system.windows.shell.windowchrome(v=vs.110).aspx" rel="nofollow noreferrer">WindowChrome class</a> for solving problem with different icons in task bar and app header. Here is my window.style example:</p>
  
  <pre><code>&lt;Window.Style&gt;
      &lt;Style TargetType="{x:Type local:MainWindow}"&gt;
          &lt;Setter Property="shell:WindowChrome.WindowChrome"&gt;
              &lt;Setter.Value&gt;
                  &lt;shell:WindowChrome GlassFrameThickness="-1" 
                                      ResizeBorderThickness="4"  
                                      UseAeroCaptionButtons="True"/&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type local:MainWindow}"&gt;
                      &lt;Grid&gt;
  
                          &lt;!-- This is the ContentPresenter that displays the window content. --&gt;
                          &lt;Border Margin="1 30 1 1" Background="White"
                                  &gt;
                              &lt;ContentPresenter Content="{TemplateBinding Content}" /&gt;
                          &lt;/Border&gt;
  
                          &lt;!-- Window Title --&gt;
                          &lt;Image Margin="5" VerticalAlignment="Top" HorizontalAlignment="Left" Width="16" Height="16" Source="some.ico"&gt;&lt;/Image&gt;
                          &lt;TextBlock Margin="25 5 0 0" VerticalAlignment="Top" TextAlignment="Left" 
  
                                     Text="{Binding RelativeSource=
                                   {RelativeSource TemplatedParent}, Path=Title}" /&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/Window.Style&gt;
  </code></pre>
  
  <p>When not maximized - my window looks as I want. 
  <a href="https://i.stack.imgur.com/jVIx7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jVIx7.png" alt=""></a></p>
  
  <p>But when maximized(by double click/maximize button click or dock to the top) the header background is black, I can't see any buttons and my icon is out of the screen bounds. :(</p>
  
  <p><a href="https://i.stack.imgur.com/soIFx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/soIFx.png" alt="enter image description here"></a></p>
  
  <p>Any suggestions? What i'm doing wrong in my style?</p>