问题描述
所有,我希望当鼠标悬停在图像上方时图像模糊(使用模糊"效果),并在鼠标离开时恢复正常.
all, I want an image to blur (using the Blur effect) when the mouse hovers over it, and return to normal when the mouse leaves.
我在基于Silverlight的项目中使用WPF 4,XAML和VB.NET 2010.
I'm using WPF 4, XAML, and VB.NET 2010 in a Silverlight-based project.
推荐答案
最简单的方法是使用VisualStateManager
并修改MouseOverState
The simplest way is to use the VisualStateManager
and modify the MouseOverState
<VisualStateGroup x:Name="CommonStateGroup">
<VisualState x:Name="MouseOverState">
<Storyboard>
<DoubleAnimation From="10" To="0" Duration="00:00:02"
Storyboard.TargetName="blurEffect"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
</Storyboard>
</VisualState>
...
</VisualStateGroup>
您可以使用Transition
分别控制Normal-> MouseOver更改和MouseOver-> Normal更改的动画.
You can use the Transition
to control the animation for the Normal -> MouseOver change and the MouseOver -> Normal change independently.
然后在显示图像的控件中具有以下Effect
:
Then in the control that displays the image have the following Effect
:
<BlurEffect Radius="10" x:Name="blurEffect"/>
这篇关于在MouseEnter上为图像添加模糊效果;在MouseLeave上删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!