alex2k8
alex2k8

Reputation: 43214

Avoid TextBox vertical stretching

How can I avoid TextBox vertical streching in following example:

<StackPanel Orientation="Horizontal">
  <Button Height="40">OK</Button>
  <TextBox Width="200"></TextBox>
</StackPanel>

Upvotes: 1

Views: 1024

Answers (3)

Cᴏʀʏ
Cᴏʀʏ

Reputation: 107508

From MSDN:

Setting the TextWrapping attribute to Wrap causes entered text to wrap to a new line when the edge of the TextBox control is reached, automatically expanding the height of the TextBox control to include room for a new line, if necessary.

So, to fix it, I think you can set TextWrapping = TextWrapping.NoWrap

Upvotes: 0

bendewey
bendewey

Reputation: 40235

Use the VerticalAlignment Property

<StackPanel Orientation="Horizontal">
  <Button Height="40">OK</Button>
  <TextBox Width="200" VerticalAlignment="Center"></TextBox>
</StackPanel>

Upvotes: 4

Whytespot
Whytespot

Reputation: 951

    <StackPanel Orientation="Horizontal">
        <Button Height="40">OK</Button>
        <TextBox Height="40" Width="200"></TextBox>
    </StackPanel>

Upvotes: 0

Related Questions