Silverlight 4: StackPanel doesn't resize, when content gets more narrow

Posted by Aaginor on Stack Overflow See other posts from Stack Overflow or by Aaginor
Published on 2010-06-22T15:04:14Z Indexed on 2012/09/23 21:38 UTC
Read the original article Hit count: 229

Filed under:
|

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>

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about stackpanel