如何将特定控件的 ZIndex 设置为最顶层 [英] How to set the ZIndex of a particular control to the topmost

查看:40
本文介绍了如何将特定控件的 ZIndex 设置为最顶层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将任何控件设置到屏幕的最顶部.例如我在数据模板或分层数据模板中有一个文本块......现在我想将此文本块设置为鼠标悬停时的最顶层.在 IsMouseOver 的触发器中将 Grid.ZIndex 值设置为 1 多次不起作用.为此,我将窗口中所有控件的 ZIndex 值设置为 -1.它在一种情况下有效,但在其他时候不起作用.

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.

如果有人能告诉我 ZIndex 的详细信息以及如何将控件设置到最顶层而不用担心其他控件,那将有很大帮助.

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.

注意:将 ZIndex 的值设置为更高的值,例如99999 也不行.

Note: setting the value of ZIndex to a higher value e.g. 99999 also doesn't work.

推荐答案

ZIndex 相对于同一 Panel 中的其他控件.高于另一个控件的数字将确保它出现在该控件的上方".

ZIndex is relative to other controls in the same Panel. A number higher than another control will ensure it appears "above" that control.

如果您的控件不在同一个 Panel 中,ZIndex 将无济于事.您可能需要提供更多关于您正在做什么的信息,但听起来 Adorner 对您更有用.

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 an Adorner will be of more use to you.

这篇关于如何将特定控件的 ZIndex 设置为最顶层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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