How to change the border thickness in mouseover

♀尐吖头ヾ 提交于 2019-12-11 09:37:10

问题


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.


回答1:


Use ObjectAnimationUsingKeyFrames instead DoubleAnimationUsingKeyFrames in your case:

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

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



来源:https://stackoverflow.com/questions/12143099/how-to-change-the-border-thickness-in-mouseover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!