如何在 wpf 中将项目置于最前面? [英] How do I bring an item to the front in wpf?

查看:28
本文介绍了如何在 wpf 中将项目置于最前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是将两个网格放在一起.给定世界的一种状态,我希望网格 A 位于顶部,给定另一种世界状态,我希望网格 B 位于顶部.在过去,我们可以只调用 grid.BringToFront(),但现在已经不存在了,我想不出任何方法来实现它.

I simply have two grid on top of one another. Given one state of the world, I want grid A to be on top, given another state of the world, I want grid B to be on top. In the old days we could just call grid.BringToFront(), but that doesn't exist anymore, and I can't figure out any way to make that happen.

我能想到的最好的办法是,我需要创建自己的自定义类来实现此功能,但对于过去如此简单的事情来说,这似乎太过分了.

The best I can figure, I need to create my own custom classes to allow this functionality, but that seems like major overkill for something that used to be so simple.

推荐答案

您可以使用 Panel.ZIndex 属性改变面板中元素的显示顺序

You can use the Panel.ZIndex property to change the display order of elements in a panel

这篇关于如何在 wpf 中将项目置于最前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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