WPF控制翻转 [英] WPF Control Flip

查看:142
本文介绍了WPF控制翻转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控件,该控件主要由图像和按钮组成。我想在图像的背面显示图像元数据,并在按下按钮时使控件水平翻转:

I've got a control that is mainly comprised of an image and a button. I want to display the image meta data on the back of the image and have the control flip horizontally when the button is pressed:

单击信息按钮...

将图像绕轴旋转180度...

Rotate the image 180 degs around the axis...

很明显,当单击红色的关闭按钮时,图像会绕最后的180度旋转,因此

Obviously when the red "close" button is clicked, the image rotates around the final 180 degs so that the image is showing again.

我还没有真正在XAML中完成任何3D操作,但是我不明白为什么这样做太复杂了……

I've not done any 3D really in XAML, but I can't see why this would be too complex...

推荐答案

无需3D即可完成。 ScaleEffect 将水平比例从 1 更改为 -1 相同的视觉效果:

It can be done without 3D. ScaleEffect with changing horizontal scale from 1 to -1 has the same visual effect:

<Image RenderTransformOrigin="0.5,0.5">
    <Image.RenderTransform>
        <ScaleTransform ScaleX="-1" />
    </Image.RenderTransform>
</Image>

您可以对 ScaleX 属性进行动画处理以获得旋转效果。您还应该将其可见性从可见更改为隐藏,反之亦然。使图像旋转90度后消失。同时,后面板也应该可见。

You can animate ScaleX property to get rotating effect. You should also change it's Viisibility from Visible to Hidden and vice versa. To make image disappearing after rotating 90 degrees. At the same time back panel should become visible.

这篇关于WPF控制翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆