Silverlight 4: StackPanel doesn't resize, when content gets more narrow
- by Aaginor
I am using Silverlight 4 with Blend 4.
I have a (horizontal) stackpanel that includes some TextBoxes and a Button. The stackpanel is set to stretch to the size that the content uses. The TextBoxes are on autosize too.
When I add text to the Textboxes, the textbox size grows and the stackpanel grows too. So far so good.
When I remove text from the textboxes, the textbox size shrinks (as excepted), but the stackpanel size doesn't.
Is there any trick to make the stackpanel change size, when the content (textboxes) getting smaller?
Thanks in advance,
Frank
Here is the XAML for the UserControl:
<Grid x:Name="LayoutRoot">
<StackPanel x:Name="StackPanelBorder" Orientation="Horizontal">
<TextBox x:Name="TextBoxCharacteristicName" TextWrapping="Wrap" Text="Tex">
</TextBox>
<TextBox x:Name="TextBoxSep" TextWrapping="Wrap" Text="=" IsReadOnly="True">
</TextBox>
<Button x:Name="ButtonRemove" Content="-" Click="ButtonAddOrRemove_Click">
</Button>
</StackPanel>
</Grid>