通常,您可以使用所谓的"透视变换"将3D效果(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中,我使用此函数对对象进行z排序:
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教程"使用投影在Silverlight 3中构建3D旋转木马"图像似乎是zindex自动切换不是什么发生在WINRT?
如果将Image
放置在Canvas中,则可以设置zIndex依赖项属性。