查看Demo
另外,还可以将 Matrix3DProjection 和 Matrix3D 类型用于比使用 PlaneProjection 可能更复杂的准三维方案。
示例代码:沿Y轴翻转:
XAML:
< Image Grid.Row ="1" Height ="147" HorizontalAlignment ="Left" Margin ="52,28,0,0" Name ="image1" Stretch ="Fill" VerticalAlignment ="Top" Width ="220" Source ="/SilverlightApplication1;component/images/61e44a60jw1dglvwijv8nj.jpg" > < Image.Projection > < PlaneProjection x:Name ="ppFlipImage" ></ PlaneProjection > </ Image.Projection > </ Image > < Button Content ="Button" Grid.Row ="1" Height ="23" HorizontalAlignment ="Left" Margin ="125,182,0,0" Name ="button1" VerticalAlignment ="Top" Width ="75" Click ="button1_Click" />
C#:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Threading; namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this .LayoutRoot.Loaded += new RoutedEventHandler(LayoutRoot_Loaded); } void LayoutRoot_Loaded( object sender, RoutedEventArgs e) { tmrY = new DispatcherTimer(); tmrY.Tick += tmrY_Tick; TimeSpan tsFlip = new TimeSpan( 0 , 0 , 0 , 0 , frequence); // 100 Milliseconds tmrY.Interval = tsFlip; } private int frequence = 10 ; private DispatcherTimer tmrY; private void button1_Click( object sender, RoutedEventArgs e) { // this.ppFlipImage.RotationY = (this.ppFlipImage.RotationY + 1) % 360; if ( ! tmrY.IsEnabled) { tmrY.Start(); } else { tmrY.Stop(); } } void tmrY_Tick( object sender, EventArgs e) { this .ppFlipImage.RotationY = ( this .ppFlipImage.RotationY + 1 ) % 360 ; } } }