日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

WPF 路径动画PathAnimations的使用

發布時間:2023/12/4 asp.net 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WPF 路径动画PathAnimations的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在wpf中讓一個控件按照一定的路徑運行的動畫。。叫做路徑動畫,這個示例演示了讓一個rectangle按照一個s形曲線反復運行的動畫。

效果:

只有一個文件:

全部代碼如下 :

<Window x:Class="wpfcore.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:wpfcore"mc:Ignorable="d"Background="LightBlue"Title="MainWindow" Width="420" Height="340"><Window.Resources><PathGeometry x:Key="SLine" Figures="M 10,100 C 35,0 135,0 160,100 180,190 285,200 310,100" /></Window.Resources><Grid Margin="20"><StackPanel><Canvas?HorizontalAlignment="Left"?Margin="0"?Width="340"?Height="215"?><Path VerticalAlignment="Top" Margin="15,15,15,15" Data="{StaticResource SLine}"Stroke="Blue" StrokeThickness="2"Stretch="None"/><Path Fill="Red"><Path.Data><RectangleGeometry x:Name="MyAnimatedRectGeometry" Rect="0,0 30 30" ><RectangleGeometry.Transform><TransformGroup><RotateTransform x:Name="MyRotateTransform" Angle="0" CenterX="15" CenterY="15" /><TranslateTransform x:Name="MyTranslateTransform" X="10" Y="100" /></TransformGroup></RectangleGeometry.Transform></RectangleGeometry></Path.Data></Path></Canvas><Button Width="80" HorizontalAlignment="Left" Content="開始動畫"><Button.Triggers><EventTrigger RoutedEvent="Button.Click"><BeginStoryboard Name="MyBeginStoryboard"><Storyboard><DoubleAnimationUsingPathStoryboard.TargetName="MyRotateTransform"Storyboard.TargetProperty="Angle"Source="Angle" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="True" PathGeometry="{StaticResource SLine}"></DoubleAnimationUsingPath><DoubleAnimationUsingPathStoryboard.TargetName="MyTranslateTransform"Storyboard.TargetProperty="X"Source="X" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="True" PathGeometry="{StaticResource SLine}"></DoubleAnimationUsingPath><DoubleAnimationUsingPathStoryboard.TargetName="MyTranslateTransform"Storyboard.TargetProperty="Y"Source="Y" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="True" PathGeometry="{StaticResource SLine}"></DoubleAnimationUsingPath></Storyboard></BeginStoryboard></EventTrigger></Button.Triggers> </Button></StackPanel></Grid> </Window>

動畫截圖:

完事,搞定。

總結

以上是生活随笔為你收集整理的WPF 路径动画PathAnimations的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。