在MouseEnter上为图像添加模糊效果;在MouseLeave上删除 [英] Add Blur Effect to Image on MouseEnter; Remove on MouseLeave

查看:132
本文介绍了在MouseEnter上为图像添加模糊效果;在MouseLeave上删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,我希望当鼠标悬停在图像上方时图像模糊(使用模糊"效果),并在鼠标离开时恢复正常.

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上删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆