c# - 如何在 3D 透视图中对 windows 8 UIElements 进行 Z 索引(Z 排序)?

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

通常,您可以使用所谓的“透视变换”将 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/

相关文章:

c# - 将 BitmapImage 设置为 null 时内存未释放

c# - 判断 Json 结果是对象还是数组

c# - 使用值从哈希表中查找

c# - 从 WinRT 中的 UI 调用 HttpClient - 没有任何反应

wpf - 带有Microsoft WPF功能区的窗口样式与Windows 8样式不匹配

html - IE7中绝对定位元素的Z-index问题

用于基准测试目的的 C# 编译器优化

c# - CRM 2011 获取没有早期绑定(bind)类型的自定义实体记录属性

html - 滚动修复 : a:hover + links in div not working any more because other div's margin is on top of that div

css - z-index,在图像上显示标题