DockPanel 内的 ZIndex
我有一个 DockPanel 作为窗口的根元素。
我有另一个 DockPanel,它本质上是一个菜单栏,设置为停靠在根元素 DockPanel 的顶部。
我希望将图像停靠在根元素 DockPanel 的顶部,该图像浮动在菜单栏 DockPanel 上。
例如:
<DockPanel x:Name="RootDockPanel">
<Image Souce="/MyProject;component/Images/imageName.jpg" DockPanel.Dock="Top" Panel.ZIndex="3" />
<DockPanel x:Name="MenuDockPanel" DockPanel.Dock="Top" Panel.ZIndex="0">
<!-- content -->
</DockPanel>
</DockPanel>
我尝试将图像的Panel.ZIndex 设置为高于菜单栏DockPanel 的Panel.ZIndex,但这不起作用。
由于 ZIndex 被证明是无用的,我不确定如何实现这一点,我正在寻找您的意见。
感谢您的帮助!
-弗林尼
I have a DockPanel as the root element for my window.
I have another DockPanel that is essentially a menu bar which is set to be docked to the Top of the root-element-DockPanel.
I would like to have an image docked to the top of the root-element-DockPanel that floats over the menu-bar-DockPanel.
For example:
<DockPanel x:Name="RootDockPanel">
<Image Souce="/MyProject;component/Images/imageName.jpg" DockPanel.Dock="Top" Panel.ZIndex="3" />
<DockPanel x:Name="MenuDockPanel" DockPanel.Dock="Top" Panel.ZIndex="0">
<!-- content -->
</DockPanel>
</DockPanel>
I have tried setting the Panel.ZIndex of the Image to something higher than the Panel.ZIndex of the menu-bar-DockPanel but this doesn't work.
Since the ZIndex is proving to be useless, I'm not sure how to accomplish this and I'm looking for your input.
Thanks for your help!
-Frinny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议简单地放弃 DockPanel 控件并使用 Grid。根据我的经验,DockPanel 是一个设计糟糕的控件,并且是 WPF 中所有面板控件中最无用的。
I recommend simply ditching the DockPanel control and using Grid instead. In my experience, DockPanel is a poorly-designed control and is the most useless of all the panel controls in WPF.
DockPanel.ZIndex
对我有用。这是一个可以提供帮助的示例(它可能无法编译,我只是凭记忆编写它来说明这个概念):
DockPanel.ZIndex
works for me.Here's an example to help (it may not compile, I just wrote it from memory to illustrate the concept):