Some times when you place TextBox inside stackpanel,it may not fill available horizontal space .In this case we need to set HorizontalAlignment="Stretch".So the following code will be work for you.
<StackPanel>
<TextBox HorizontalAlignment="Stretch" />
</StackPanel>