如何更改鼠标悬停的边框厚度 [英] How to change the border thickness in mouseover

查看:123
本文介绍了如何更改鼠标悬停的边框厚度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的控件的样式。我想换一个控制了borderThickness,当鼠标悬停完成。我想在这种风格本身写写它在codebehind这不是

I'm working on the styles of controls. I want to change the borderthickness of a control when the mouseover is done. I want to write this in the style itself instead of writing it in codebehind

所以,我试图以下列方式

So, I tried in the following way.

<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
<SplineDoubleKeyFrame  KeyTime="0" Value="2" />                                   
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

但是,这是抛出一个错误。

But this is throwing an error.

我怎样才能实现这一功能。

How can I achieve this functionality.

推荐答案

使用 ObjectAnimationUsingKeyFrames ,而不是 DoubleAnimationUsingKeyFrames 你的情况

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
    <DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
</ObjectAnimationUsingKeyFrames>

DoubleAnimationUsingKeyFrames 动画一个双击属性的值,而了borderThickness 厚度的类型,而不是双击

DoubleAnimationUsingKeyFrames animates the value of a Double property, whereas BorderThickness is type of Thickness, not Double.

这篇关于如何更改鼠标悬停的边框厚度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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