网格行高调整

发布于 2024-09-05 13:58:57 字数 91 浏览 3 评论 0原文

我在网格中有两个扩展器,都在自动调整大小的行中。 当 Expander 的高度很大时,行会溢出网格。

有没有办法让自动调整行大小,只占用可用的网格空间?

I have two Expanders in a grid, both in Auto sized rows.
When the height of the Expander is very large, the row overflows out of the grid.

Is there a way to have Auto sized rows that take only the grid space that's available?

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

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

发布评论

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

评论(4

失退 2024-09-12 13:59:28

请参阅此处我的自定义自动调整大小面板/网格类。我专门写它来解决这个问题——完整的源代码在问题中。

(要使用它,请创建一个继承自面板的新类,并将工作代码粘贴到该类中,然后像 StackPanel 一样使用自定义类。)

它目前仅支持垂直方向,但可以轻松修改以支持水平方向。

See my custom auto-sizing panel/grid class here. I wrote it specifically to address this problem--full source is in the question.

(To use it, create a new class that inherits from panel and paste the working code into the class, then use the custom class just like a StackPanel.)

It currently only supports Vertical orientation, but could easily be modified to support Horizontal as well.

追我者格杀勿论 2024-09-12 13:59:24

我会将最后一个 rowDefinition 设置为 Height="*",
然后最后一行填充所有剩余空间。

但如果不仅最后一行会溢出,这也无济于事。

i would set the last rowDefinition to Height="*",
then the last row fills out all the space left.

but it doesnt help if not only the last row would overflow..

倾其所爱 2024-09-12 13:59:22

您可以使用 DockPanel 来代替 - 然后停靠第一个底部并让另一个填充。或者将每个 Expander 放入 ScrollViewer 中。

You could use a DockPanel instead - and then dock the first Bottom and let the other fill. Or put each Expander inside a ScrollViewer.

小红帽 2024-09-12 13:59:18

尝试在扩展器对象或扩展器内部的对象上设置 MaxHeight 属性。

Try setting the MaxHeight property on either the expander object or the object inside the expander.

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