WPF 在具有 MaxHeight 的 VerticalAlign 拉伸上停靠到顶部
我正在寻找一种结合了 VerticalAlign="Stretch"
和 VerticalAlign="Top"
的行为。请遵守以下标记:
<Border BorderThickness="2" BorderBrush="Black" MaxHeight="200">
...
</Border>
这将按照我的预期进行,直到 Border 容器的高度超过 200。此时,Border 的高度变为 200,并位于其容器的中心。
我无法使用 DockPanel.Dock="Top" 将其包装在 DockPanel 中。我也无法将其容器设置为 VerticalAlign="Top"。原因是这两者都会导致 Border 不再垂直扩展以填充容器可用空间(最多 200 个)。
因此,为了解决此问题,必须满足以下条件:
- Border 必须扩展以填充其父级的可用空间,直到达到其 MaxHeight。
- 边框的上边缘必须与其父边框的上边缘相交。
- 边框不必是
。
I'm seeking a behaviour which combines that of VerticalAlign="Stretch"
and VerticalAlign="Top"
. Please observe the following markup:
<Border BorderThickness="2" BorderBrush="Black" MaxHeight="200">
...
</Border>
This acts as I intend it to until the container of Border becomes greater than 200 tall. At this point, Border becomes 200 tall and centers itself in its container.
I cannot wrap it in DockPanel with DockPanel.Dock="Top". I also cannot set its container to VerticalAlign="Top". The reason is that both of these cause Border to no longer expand vertically to fill the containers available space (up to 200).
So, in order to consider this problem solved, the following must occur:
- Border must expand to fill its parent's available space up until its MaxHeight is reached.
- Border's top edge must meet its parent's top edge.
- Border does not need to be a
<Border>
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
瞧:
voila: