I’ve had the same problem with StackPanel
, and the behavior is “by design”. StackPanel
is meant for “stacking” things even outside the visible region, so it won’t allow you to fill remaining space in the stacking dimension.
You can use a DockPanel
with LastChildFill
set to true
and dock all the non-filling controls to the Left
to simulate the effect you want.
<DockPanel Background="Orange" LastChildFill="True">
<TextBlock Text="a label" Margin="5"
DockPanel.Dock="Left" VerticalAlignment="Center"/>
<TextBox Height="25" Width="Auto"/>
</DockPanel>