在不使用Canvas控件的情况下,在Silverlight中控制渲染顺序(ZOrder) [英] Controlling rendering order (ZOrder) in Silverlight without using the Canvas control

查看:117
本文介绍了在不使用Canvas控件的情况下,在Silverlight中控制渲染顺序(ZOrder)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Silverlight 2中的UserControl通过编程方式添加到另一个控件中,方法是将其添加到父控件的"Children"集合中.起初,这很好.如果我对窗口做了其他操作(在我的情况下,我将整个面板从视图中滚动出来,然后又重新回到视图中),那么它显然会更改渲染顺序并使我的控​​件位于其他控件的后面.我正在寻找一种控制此行为的方法,以强制将窗口置于顶部. Canvas控件具有ZOrder属性,可用于设置此属性,但是我没有使用Canvas,而是使用了Grids.

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.

我一直在使用Children.Insert并弄乱索引,这也会改变渲染顺序,但这似乎是解决问题的一种笨拙的方式.如何强制我的控件居于首位?

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?

-马特

推荐答案

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

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.

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

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/zh-CN/library/system.windows.controls.canvas.zindex(VS.95).aspx

这篇关于在不使用Canvas控件的情况下,在Silverlight中控制渲染顺序(ZOrder)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆