title: Why is there a gap between border's border and border's background in wpf?
body: <p>The following code:</p>
  
  <pre><code>&lt;Window x:Class="WpfApp1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          mc:Ignorable="d"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;Border Background="Red"&gt;
              &lt;Border BorderThickness="10" BorderBrush="Black" Background="Black"/&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>produces the following output (.NET 4.6.1, Windows 10):</p>
  
  <p><a href="https://i.stack.imgur.com/du9an.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/du9an.png" alt="enter image description here"></a></p>
  
  <p>The red line should not be there. It seems to be a gap between the second border's border and the second border's background. I tried to set <code>SnapsToDevicePixels</code> to <code>True</code> but it doesn't change.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As suggested in the answers, <code>RenderOptions.EdgeMode="Aliased"</code> seems to solved the issue. But in fact I think it better highlight a bug in WPF. Because now, the following code:</p>
  
  <pre><code>&lt;Window x:Class="WpfApp1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          mc:Ignorable="d"
          RenderOptions.EdgeMode="Aliased"
          SnapsToDevicePixels="True"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;Border Background="Red"&gt;
              &lt;Border Margin="10" BorderThickness="1" BorderBrush="Black"&gt;
                  &lt;Grid Background="Black"/&gt;
              &lt;/Border&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>produces the following output:
  <a href="https://i.stack.imgur.com/Aa8Ms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Aa8Ms.png" alt="enter image description here"></a></p>