Moving an image to the background?

I make a game in which I move images around. I have two large images that should have smaller images on top of them. I often move smaller images from one of the larger images to another. However, I recently added a feature in which a large image changed in the middle of the game. This made him take precedence over smaller images, and when I move small images, they end up moving behind large images.

In short, I always want large images to be in the background, and small ones in the foreground. Is there a property that I can set for those to happen?

+43
c # wpf
Aug 01 '14 at 4:22
source share
1 answer

If you have several user interface elements in a specific grid cell, the elements overlap each other on top of each other. Elements added earlier in XAML are displayed lower (lower level) than elements added later.

You can change the layering of elements by changing the order in which they are added to the grid. You can also control the bundle by providing each element with a value for Panel.ZIndex. Elements with higher values ​​for ZIndex will be displayed on top of elements with lower values, regardless of the order in which they were added to the grid.

Source: http://wpf.2000things.com/tag/zindex/

MSDN page in the ZIndex property: http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.zindex%28v=vs.110%29.aspx

+31
Aug 01 '14 at 4:38
source share



All Articles