【问题标题】:How to Z-Index(Z-Sorting) windows 8 UIElements in 3D Perspective?如何在 3D 透视图中 Z-Index(Z-Sorting)windows 8 UIElements?
【发布时间】:2012-08-06 01:08:01
【问题描述】:

一般来说,您可以使用所谓的“透视变换”将 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 中发生的事情吗?

【问题讨论】:

    标签: c# windows-8 z-index transform uielement


    【解决方案1】:

    如果您将Image 放在Canvas 中,您将能够设置zIndex dependency property

    【讨论】:

    • 但是如何对它们进行 zindex 透视呢?像 3D 轮播或旋转立方体中的图像?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-21
    • 1970-01-01
    • 2011-10-22
    相关资源
    最近更新 更多