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-Dock开发者_开发问答Panel 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
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
works for me.
Here's an example to help (it may not compile, I just wrote it from memory to illustrate the concept):
<DockPanel>
<Label
Background="Yellow"
Content="Foo"
DockPanel.Dock="Right"
DockPanel.ZIndex="1"
/>
<Label
Background="Green"
Content="Bar"
DockPanel.Dock="Right"
DockPanel.ZIndex="0"
/>
</DockPanel>
精彩评论