通常,您可以使用所谓的“透视变换”将 3-D 效果(x、y、z、rotationX、rotationY、rotationZ...)应用于任何 UIElement
:
<Image x:Name="img1" HorizontalAlignment="Left" Height="200" Width="200" Source="img1.jpg">
<Image.Projection>
<PlaneProjection CenterOfRotationY="3" RotationX="40"/>
</Image.Projection>
</Image>
但没有 Z 索引(Z 排序)! 当 UIElements 重叠时,它们无法正确呈现。
在 AS3 中我使用这个函数对对象进行 zsort :
public function zSort():void
{
var i:uint;
var zList:Array = [];
for (i=0; i<this.numChildren; i++)
{
var mtx:Matrix3D = this.getChildAt(i).transform.getRelativeMatrix3D(this.parent);
zList.push( { sp:this.getChildAt(i), z:mtx.position.z } );
}
zList.sortOn("z", Array.NUMERIC | Array.DESCENDING);
for (i=0; i<this.numChildren; i++)
{
this.setChildIndex(zList[i].sp, i);
}
}
在c#中有类似的解决方案吗?或者事情在 Windows 8 中工作不同?
我找到了这个 Silverlight 教程 "Using projection to build a 3D carousel in Silverlight 3" 图像似乎是 zindex 自动女巫是不是在 WINRT 中发生了什么?
最佳答案
如果您将Image
放在Canvas 中,您将能够设置 zIndex dependency property .
关于c# - 如何在 3D 透视图中对 windows 8 UIElements 进行 Z 索引(Z 排序)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11821488/