How can I avoid TextBox vertical streching in following example:
<StackPanel Orientation="Horizontal">
<Button Height="40">OK</Button>
<TextBox Width="200"></TextBox>
</StackPanel>
How can I avoid TextBox vertical streching in following example:
<StackPanel Orientation="Horizontal">
<Button Height="40">OK</Button>
<TextBox Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Height="40">OK</Button>
<TextBox Height="40" Width="200"></TextBox>
</StackPanel>
Use the VerticalAlignment Property
<StackPanel Orientation="Horizontal">
<Button Height="40">OK</Button>
<TextBox Width="200" VerticalAlignment="Center"></TextBox>
</StackPanel>
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