Silverlight4 how to make Canvas ZIndex top-most when inside a StackPanel
Posted on 2010-11-20
Problem: Need to fly a message above all other elements on screen, where the obvious solution of using a Canvas messes up the use of a list-wrapping display.
Background: I have a Silverlight4 application that is working great, correctly displaying a ListBox with a WrapPanel item template where it must be configured to use up all remaining space on the screen, after allowing for a heading area on top. All of this is coordinated through a StackPanel to lay out the overall screen.
I need to be able to display messages on top of all of this without disturbing the layout. A Canvas tucked inside the heading area is working great, and I can position messages with the canvas exactly where I want.
The only problem is the message is always behind the other items on screen regardless of the ZIndex. This makes sense from the perspective that the other items are not inside the canvas but rather the canvas is inside the other items, rendering the ZIndex moot.
When I try to enclose the entire screen layout in a Canvas it looses desired WrapPanel behavior, which is essential to the design.
Question: Is there a way to fly an element above all others without basing the entire layout on a Canvas? My only idea is a ChildWindow without a border but that seems overkill for what I need to do.