windows phone 中的两张图像重叠情况

Two images overlapping case in windows phone

假设我有一个网格,其中我放置了两张图片 A 和 B。两张图片始终可见,因为边距是这样设置的。这里因为首先绘制 A,所以 B 是完全可见的,部分重叠 A,因此 A 是部分可见的。我的问题来了:我想改变这种行为运行时,即 A 是完全可见的,B 是部分可见的。因为我不能先重画 B 然后再重画 A 才能发生这种情况。我们有 属性 或 windows phone 中的 Depth 之类的东西吗?

您可以设置Canvas ZIndex(或Panel ZIndex)

详细了解 Canvas.ZIndex here on MSDN

如果你想在代码后面设置它,你可以这样做:

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