Theo
Theo

Reputation: 588

C# XAML Universal Apps - Change StackPanel's width as TextBoxes inside grow

I have a few TextBoxes inside a StackPanel like this:

...
<StackPanel Orientation="Horizontal">
  <TextBox Text="1"></TextBox>
  <TextBox Text="1"></TextBox>
  <TextBox Text="1"></TextBox>
</StackPanel>
...

I would like the StackPanel to grow as the TextBoxes are typed into, but instead, the TextBoxes wrap as more text is added.

How can I make the StackPanel to grow as the TextBoxes are typed into?

Thanks in advance!

Upvotes: 0

Views: 33

Answers (1)

wake-0
wake-0

Reputation: 3968

When I try your solution it works for me. But you could try to add the property TextWrapping="NoWrap" to each TextBox or create a Style.

Or you could use instead of a StackPanel a Grid which does also work

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefiniton Width="Auto" />
        <ColumnDefiniton Width="Auto" />
        <ColumnDefiniton Width="Auto" />
    </Grid.ColumnDefinitions>

    <TextBox Grid.Column="0" Text="1" />
    <TextBox Grid.Column="1" Text="1" />
    <TextBox Grid.Column="2" Text="1" />
</Grid>

Upvotes: 1

Related Questions