Have you tried adjusting the horizontal and vertical alignment properties of the StackPanel? You do not need to bind the Width and Height properties of the parent container at all.
StackPanel , , Border, . . :
<Style x:Name="mytemplate" x:Key="mytemplate" xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="ContentTemplate" >
<Setter.Value>
<DataTemplate>
<Border Background="Aqua" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<StackPanel>
<TextBlock Text="{Binding}" HorizontalAlignment="Center" FontWeight="Black" ></TextBlock>
<TextBox x:Name="{Binding}" Padding="0,-1,0,0" HorizontalAlignment="Stretch" Width="100" Height="20" KeyDown="txtfilterBox_KeyDown" LostFocus="txtfilterBox_LostFocus" />
</StackPanel>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>