Search code examples
wpfheightstretching

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>

Solution

  • Use the VerticalAlignment Property

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