Search code examples
c#imagewindows-phone-8.1marginwindows-phone-store

Two images overlapping case in windows phone


Consider I have a grid in that I place two images A and B. Both are visible all the times as margins are set like that. Here as A is drawn first so B is completely Visible overlapping A partially and hence A is Partially visible. Here my Question comes : I want to alternate this behavior runtime that is , A is completely Visible and B is partially. As I can not redraw B first then A for this to happen. Do we have any property or something like Depth in windows phone?


Solution

  • You can set Canvas ZIndex (or Panel ZIndex)

    Read more about Canvas.ZIndex here on MSDN.

    If you want to set it in code behind, you can do this:

    someImage.SetValue(Canvas.ZIndexProperty, 1); 
    someOtherImage.SetValue(Canvas.ZIndexProperty, 2);