如何将特定控件的 ZIndex 设置到最顶层
如何将任何控件设置到屏幕的最顶部。例如,我在数据模板或分层数据模板中有一个文本块......等等......现在我想在鼠标悬停时将此文本块设置为最上面。在 IsMouseOver 触发器中将 Grid.ZIndex 值设置为 1 多次不起作用。为了做到这一点,我在窗口中将所有控件的 ZIndex 值设置为 -1。它在一种情况下有效,但在其他情况下不起作用。
如果有人能让我了解 ZIndex 的详细信息以及如何将控件设置到最顶层而不用担心其他控件,那将会有很大的帮助。
注意:将 ZIndex 的值设置为更高的值(例如 99999)也不起作用。
how do i set any control to the topmost of the screen. For e.g. i have a textblock in a datatemplate or a hierarchichal data template..etc... now i would like to set this textblock to the topmost on mouseover. Setting the Grid.ZIndex value to 1 in the trigger for IsMouseOver doesn't work many times. In order to do that i set the ZIndex value for all the contols to -1 in the window. it worked in one scenario but doesn't work other times.
If anyone can get me the details of ZIndex and how to set the control to the topmost without worrying about the other controls, it would be of great help.
Note: setting the value of ZIndex to a higher value e.g. 99999 also doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ZIndex
是相对于同一Panel
中的其他控件的。高于另一个控件的数字将确保它出现在该控件的“上方”。如果您的控件并非全部位于同一个
Panel
中,则ZIndex
将无法为您提供帮助。您可能需要提供有关您正在做什么的更多信息,但听起来Adorner
对您来说更有用。ZIndex
is relative to other controls in the samePanel
. A number higher than another control will ensure it appears "above" that control.If your controls aren't all in the same
Panel
,ZIndex
won't help you. You may need to give more information on exactly what you're doing, but it sounds like anAdorner
will be of more use to you.