0

I have a grid where I'm going to add images dynamically in code-behind. I need to set the ZIndex properties of those images to get the desired look.

I don't want to use Canvas if there's a way without it, the grid already contains images that are transformed in animations and adding a canvas messed up their positions immediately. I can set the ZIndex property in XAML, so I assume it is possible in code-behind as well.

How can I change a the ZIndex property of an image in a grid in code-behind?

polarka
  • 546
  • 1
  • 5
  • 9
  • 1
    `Panel.SetZIndex()` works in every Panel. – Clemens Jun 07 '16 at 13:28
  • I was thinking about that. But it seems I have failed to use it. My grid is called MapGrid. The image is named MapIcon. I have tried MapGrid.SetZIndex(), but it is not recognised. It's missing from the available methods. – polarka Jun 07 '16 at 13:37
  • Grid.SetZIndex(MapIcon, 3); Solved my problem. One shouldn't refer to the instance of the grid, but the type. The problem was more of a syntactical one. I must have failed to emphasize that. Thanks Clemens for reinforcing the idea that I must use "Panel.SetZIndex()" somehow. – polarka Jun 07 '16 at 13:59

0 Answers0