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

时间:2012-08-27 13:36:42

标签: .net silverlight styles blend

我正在研究控件的样式。我想在鼠标悬停完成后更改控件的borderthickness。我想在样式本身中编写它,而不是在codebehind

中编写它

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

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

但这是一个错误。

如何实现此功能。

1 个答案:

答案 0 :(得分:5)

在您的案例中使用ObjectAnimationUsingKeyFrames代替DoubleAnimationUsingKeyFrames

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

DoubleAnimationUsingKeyFrames动画显示Double属性的值,而BorderThickness的类型为Thickness,而不是Double

相关问题