避免 TextBox 垂直拉伸

发布于 2024-07-15 07:01:22 字数 213 浏览 3 评论 0原文

在以下示例中如何避免 TextBox 垂直拉伸:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

女中豪杰 2024-07-22 07:01:22

使用 VerticalAlignment 属性

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

Use the VerticalAlignment Property

<StackPanel Orientation="Horizontal">
  <Button Height="40">OK</Button>
  <TextBox Width="200" VerticalAlignment="Center"></TextBox>
</StackPanel>
风吹雪碎 2024-07-22 07:01:22
    <StackPanel Orientation="Horizontal">
        <Button Height="40">OK</Button>
        <TextBox Height="40" Width="200"></TextBox>
    </StackPanel>
    <StackPanel Orientation="Horizontal">
        <Button Height="40">OK</Button>
        <TextBox Height="40" Width="200"></TextBox>
    </StackPanel>
白馒头 2024-07-22 07:01:22

来自 MSDN:

将 TextWrapping 属性设置为
换行使输入的文本换行到
TextBox 边缘时换行
自动达到控制
扩大文本框的高度
控制以包含新的空间
线,如有必要。

因此,要解决此问题,我认为您可以设置 TextWrapping = TextWrapping.NoWrap

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文