在 Silverlight 中控制渲染顺序 (ZOrder),而不使用 Canvas 控件

发布于 2024-07-13 18:37:36 字数 354 浏览 4 评论 0原文

我以编程方式将 UserControl 添加到 Silverlight 2 中的另一个,方法是将其添加到父控件的“Children”集合中。 起初这工作正常。 如果我对窗口执行其他操作(在我的情况下,我将整个面板滚动到视图之外,然后返回视图),那么它显然会更改渲染顺序并导致我的控件位于其他控件的后面。 我正在寻找一种方法来控制这种行为,强制我的窗口位于顶部。 Canvas 控件有一个 ZOrder 属性,允许您设置它,但我没有使用 Canvas,我使用的是 Grid。

我尝试过使用 Children.Insert 并弄乱索引,这也改变了渲染顺序,但这似乎是解决该问题的一种笨拙的方法。 我怎样才能强制我的控件位于顶部?

——马特

I'm programmatically adding a UserControl to another in Silverlight 2 by adding it to the parent control's "Children" collection. At first this works fine. If I do something else to the window (in my case I'm scrolling the entire panel out of view then back into view) then it apparently changes the render order and causes my control to be behind the others. I'm searching for a way to control this behavior, to force my window to be on top. The Canvas control has a ZOrder property that allows you to set this, but I am not using a Canvas, I'm using Grids.

I've played with using Children.Insert and messing with the index and that changes the render order as well, but that seems like a kludgey way to address the issue. How can I force my control to be on top?

--Matt

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

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

发布评论

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

评论(3

时常饿 2024-07-20 18:37:36

Canvas.ZIndex 适用于 Grid(以及从 UIElement 派生的任何其他控件)。

正如您可以从 http://msdn.microsoft.com 看到的/en-us/library/bb979730(VS.95).aspx 任何从 UIElement(Silverlight 中所有呈现元素的基类)派生的内容都支持 Canvas.ZIndex 属性,以及 Canvas.Top 和 Canvas 。左边。

Canvas.ZIndex will work for a Grid (and any other control derived from UIElement).

As you can see from http://msdn.microsoft.com/en-us/library/bb979730(VS.95).aspx Anything that derives from UIElement (the base class for all rendered elements in Silverlight) supports the Canvas.ZIndex property, as well as Canvas.Top and Canvas.Left.

在巴黎塔顶看东京樱花 2024-07-20 18:37:36

在网格中,ZOrder 应由顺序或子项决定。 位置 0 位于底部,位置 1 位于位置 0 的顶部,依此类推。

我不确定我是否同意您可以将 Canvas.ZIndex 与网格一起使用 - 它是画布的附加属性,因此仅当您的网格位于画布中时才可用。

http://msdn .microsoft.com/en-us/library/system.windows.controls.canvas.zindex(VS.95).aspx

In a Grid, the ZOrder should be dictated by the order or the Children. Position 0 being at the bottom, position 1 being on top of position 0 and so on.

I'm not sure I agree that you can use Canvas.ZIndex with a grid - it's an attached property of the Canvas, so would only be available if your Grid where in a Canvas.

http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.zindex(VS.95).aspx

爱给你人给你 2024-07-20 18:37:36

您应该能够在网格中使用 Canvas.ZIndex ,它实际上命名错误,应该是 Panel.ZIndex 但它应该可以工作。

You should be able to use Canvas.ZIndex in a Grid, it's actually misnamed and should be Panel.ZIndex but it should work.

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