为什么这个 WPF 应用程序中的缓动不完全在 Blend 中完成
Why isn't the easing working in this WPF app done entirely in Blend
我无法理解为什么缓动在我的应用程序中不起作用。作为测试,我在 Blend 中创建了一个非常简单的应用程序,但它在那里也不起作用。我的测试应用程序如下。 Border 的动画效果很好,但没有缓和效果。我错过了什么?
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="border">
<EasingDoubleKeyFrame KeyTime="0" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="343.43"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</Window.Triggers>
<Grid>
<Border x:Name="border" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="57.926" Margin="36.854,0,0,27.098" VerticalAlignment="Bottom" Width="67.683" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
</Grid>
</Window>
第一个动画的 Easing KeyTime 设置为零秒,看起来没有动画,这可能解释了为什么它看起来不起作用。通过在一秒钟内将边框从屏幕左侧拖动到右侧,第二个动画似乎正在运行。
我引用的代码片段:
<EasingDoubleKeyFrame KeyTime="0" Value="0">
我无法理解为什么缓动在我的应用程序中不起作用。作为测试,我在 Blend 中创建了一个非常简单的应用程序,但它在那里也不起作用。我的测试应用程序如下。 Border 的动画效果很好,但没有缓和效果。我错过了什么?
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="border">
<EasingDoubleKeyFrame KeyTime="0" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="343.43"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</Window.Triggers>
<Grid>
<Border x:Name="border" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="57.926" Margin="36.854,0,0,27.098" VerticalAlignment="Bottom" Width="67.683" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
</Grid>
</Window>
第一个动画的 Easing KeyTime 设置为零秒,看起来没有动画,这可能解释了为什么它看起来不起作用。通过在一秒钟内将边框从屏幕左侧拖动到右侧,第二个动画似乎正在运行。
我引用的代码片段:
<EasingDoubleKeyFrame KeyTime="0" Value="0">