Why doesn\'t a textbox stretch to fill space in a stackpanel? Is this by design? In a grid, the textbox stretches as expected.
Kent's answer seems right.
To still force override the StackPanel behavior, I think you'd need to dynamically compute-set the Width property of the contained elements OR some funky override of MeasureOverride. I'd rather use another layout manager/panel. Some things I noted..
The StackPanel will stretch elements based on its Orientation property value. So
StackPanel
The default value is stretch for both HorizontalAlignment and VerticalAlignment of content that is contained in a StackPanel.
HorizontalAlignment
When Height and Width properties are explicitly set on an element, these measurements take higher precedent during layout and will cancel the typical effects of setting HorizontalAlignment to Stretch.