使用WPF的外部流畅动画
问题描述:
我对ToggleButton
应用了OuterGlowBitmapEffect
。我给这个发光体添加了动画,让它产生了一种脉动效应,引起了人们的注意。我的问题是,如果我在一秒钟内放慢动画速度,它会造成很多结局。我怎样才能防止口吃发生,这是什么原因导致它不光滑?使用WPF的外部流畅动画
下面是按钮:
<ToggleButton x:Name="btnMap1" Click="btnMap1_Click" Style="{DynamicResource GenericButton}" Width="152" Height="127" IsChecked="True">
<ToggleButton.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="White" GlowSize="0" Noise="0" Opacity="1" />
</ToggleButton.BitmapEffect>
</ToggleButton>
这里是动画:
<Storyboard x:Key="ButtonGlow" RepeatBehavior="Forever" Timeline.DesiredFrameRate="30">
<DoubleAnimation
BeginTime="00:00:00"
Storyboard.TargetName="btnMap1"
Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"
From="0.0"
To="10.0"
Duration="0:0:1"
AutoReverse="True"
/>
</Storyboard>
答
这种效果是非常CPU密集型的,因为它是软件渲染而非GPU产生的。
Microsoft has deprecated this and similar effects and discourages their use。
位图的效果不应适用 大的视觉效果或动画,因为这 可能会降低性能。
他们建议改用BlurEffect
。