I am trying to simulate a tab control using nice TabHeader and TabContent. The control should look something like this:

This is achieved by setting "Margin" the first header - "HOME" to Margin = "2 0 2 -1".
RELEASE: if I resized the window to a certain smaller width, the title element visually fixed its contents. Here is the result:

I really would like to know why this is happening and how I avoid it.
Xaml example to prove the problem:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="550" Width="525">
<Grid Margin="0 50">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border BorderThickness="1" BorderBrush="Black" Grid.Row="1"/>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Border Width="50" Margin="2 0 2 -1" BorderThickness="1 1 1 0" BorderBrush="Black" Background="White">
<TextBlock Text="HOME" />
</Border>
<Border Width="150" Margin="2 -20" Height="20" BorderThickness="1 1 1 0" >
<TextBlock Text="EDIT" />
</Border>
</StackPanel>
</Grid>
source
share