如何在鼠标悬停时更改边框粗细

Shr*_*key 1 .net silverlight styles blend

我正在研究控件的风格.我想在鼠标悬停完成后更改控件的borderthickness.我想在样式本身中编写它,而不是在代码隐藏中编写它

所以,我尝试了以下方式.

<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
<SplineDoubleKeyFrame  KeyTime="0" Value="2" />                                   
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
Run Code Online (Sandbox Code Playgroud)

但这是一个错误.

我该如何实现此功能.

Zab*_*sky 5

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

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
    <DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
</ObjectAnimationUsingKeyFrames>
Run Code Online (Sandbox Code Playgroud)

DoubleAnimationUsingKeyFrames动画一个的值Double属性,而BorderThickness为类型的Thickness,而不是Double.