如何使扩展器扩展到网格行

发布于 11-03 18:38 字数 1460 浏览 5 评论 0原文

我一直在寻找这个问题的答案,但我找到的所有解决方案都无法正常工作。
问题就在这里。我有基于网格的界面,如下所示:


| __________________________________|
|(v)expander |(v)expander  |(v)expander |  <- grid inside the row of main grid
|___________________________________|
|                                        |
|                                        |
|                                        |
.                                        . <- grid, stackpanel, etc. inside row
.                                        .
.                                        .
|                                        |
|___________________________________|
|(^)expander  | (^) expander   |         | <- grid inside the row of main grid
|___________________________________|

每个扩展器都放置在它自己的边界上。
现在我希望扩展器能够扩展到接口的其余部分。顶部扩展器向下扩展,底部扩展器向上扩展。我无法使用 RowSpan。我想应该用 zIndex 来完成,但我尝试了很多次但没有成功。我将所有网格和边框Panel.ZIndex属性设置为99,并且扩展器的内容设置在ZIndex上大约999。

有什么办法可以做到吗?
谢谢,

I was looking for the answer of this, but all solutions I've found was not working properly.
Here is the problem. I have interface,based on grid like the below:


| __________________________________|
|(v)expander |(v)expander  |(v)expander |  <- grid inside the row of main grid
|___________________________________|
|                                        |
|                                        |
|                                        |
.                                        . <- grid, stackpanel, etc. inside row
.                                        .
.                                        .
|                                        |
|___________________________________|
|(^)expander  | (^) expander   |         | <- grid inside the row of main grid
|___________________________________|

Each expander is placed on it's own border.
Now I want expanders to expand over the rest of interface. Top expanders expand down, bottom ones - up. I can't use RowSpan. It should be done with zIndex somehow I guess, but I was trying with that in a lot and didn't work. I set all grids and borders Panel.ZIndex property to let's say 99, and the content of expander was set on ZIndex about 999.

Is there any way to do it?
Thanks,
Joe

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

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

发布评论

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

评论(2

不忘初心2024-11-10 18:38:24

一段时间后(当我一直在做其他事情来刷新我对这个主题的想法时)我找到了解决方案。它基于 Karl Shifflet 解决方案 ( http://karlshifflett.wordpress.com/2008/02/05/wpf-sample-series-expander-control-with-popup-content/)。
我将容纳顶部扩展器的网格放置在画布上。我将 Canvas Panel.ZIndex 属性设置为大约 99,并将背景设置为所需的颜色。 Grid.Background 属性设置为透明和 Width 以填充画布大小:

Background="Transparent" Width="{Binding RelativeSource=
  {RelativeSource Mode=FindAncestor, AncestorType={x:Type Canvas}}, 
  Path=ActualWidth}"

重要的是将所有扩展器 VerticalAlignment 设置为顶部,因为当其中一个扩展器展开,网格高度(在这种情况下不应硬定义)也会调整大小,并且当它们的垂直对齐方式未设置为顶部时,所有扩展器都放置在中间。

我希望它能帮助某人。

After a while (when I have been doing sth else to refresh my mind on this topic) I found the solution. It is based on Karl Shifflet solution ( http://karlshifflett.wordpress.com/2008/02/05/wpf-sample-series-expander-control-with-popup-content/ ).
I placed the Grid that holds top expanders onto the Canvas. I set the Canvas Panel.ZIndex property to about 99 and set the Background to desired colour. The Grid.Background property was set to Transparent and Width to fill canvas size:

Background="Transparent" Width="{Binding RelativeSource=
  {RelativeSource Mode=FindAncestor, AncestorType={x:Type Canvas}}, 
  Path=ActualWidth}"

Important thing was to set all expanders VerticalAlignment to Top, because when one of them expands, the Grid Height (which should not be hard defined in this case) also resizes, and when Vertical Alignment of them is not set to Top, all expanders are placed in the middle.

I hope it helps someone.

多像笑话2024-11-10 18:38:24

如果您想保证它出现在顶部,您可能需要使用弹出窗口而不是扩展器。

You may want to use a pop up instead of an expander if you want to guarantee that it will appear on top.

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