1 <Window x:Class="Easing2.MainWindow"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns:local="clr-namespace:Easing2"
5 Title="MainWindow" Height="350" Width="525">
6
7 <Window.Resources>
8 <Storyboard x:Key="AnimateTarget">
9 <!--Storyboard.TargetName,获取或设置要进行动画处理的对象的名称。
10 Storyboard.TargetProperty,获取或设置应进行动画处理的属性。-->
11
12 <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Transform" Storyboard.TargetProperty="X">
13 <!--EasingDoubleKeyFrame类,通过它可以将缓动函数与 DoubleAnimationUsingKeyFrames 关键帧动画相关联-->
14 <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0.0">
15 <!--EasingDoubleKeyFrame,Value获取或设置关键帧的目标值。-->
16 </EasingDoubleKeyFrame>
17
18 <EasingDoubleKeyFrame KeyTime="0:0:4" Value="100.0">
19 <!--EasingDoubleKeyFrame.EasingFunction获取或设置应用于关键帧的缓动函数。-->
20 <EasingDoubleKeyFrame.EasingFunction>
21 <!--这里使用了DP Power-->
22 <local:CustomPowerEase Power="20" />
23 </EasingDoubleKeyFrame.EasingFunction>
24 </EasingDoubleKeyFrame>
25
26 </DoubleAnimationUsingKeyFrames>
27
28 <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Transform" Storyboard.TargetProperty="Y">
29
30 <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0.0">
31 </EasingDoubleKeyFrame>
32
33 <EasingDoubleKeyFrame KeyTime="0:0:4" Value="100.0">
34
35 <EasingDoubleKeyFrame.EasingFunction>
36
37 <!--<PowerEase EasingMode="EaseIn" Power="5"/>-->
38 <!--PowerEase.EaseInCore,此成员重写 EasingFunctionBase.EaseInCore(Double),
39 提供缓动函数的逻辑部分,通过重写此部分可以生成自定义缓动函数的 EaseIn 模式。
40 -->
41 <local:CustomPowerEase Power="10" />
42 </EasingDoubleKeyFrame.EasingFunction>
43
44 </EasingDoubleKeyFrame>
45 </DoubleAnimationUsingKeyFrames>
46
47 </Storyboard>
48 </Window.Resources>
49
50 <Grid>
51 <Rectangle Width="20" Height="20" Fill="Red" RenderTransformOrigin="0.5, 0.5">
52 <Rectangle.RenderTransform>
53 <TranslateTransform x:Name="Transform" />
54 </Rectangle.RenderTransform>
55 </Rectangle>
56
57 <Button Width="100" Height="40" Content="Start Animation" Click="Button_Click"
58 HorizontalAlignment="Center"
59 VerticalAlignment="Bottom" />
60 </Grid>
61 </Window>