如何更改鼠标悬停的边框厚度鼠标、边框、厚度、如何更改

由网友(<婳影>)分享简介:我工作的控件的样式。我想换一个控制了borderThickness,当鼠标悬停完成。我想在这种风格本身写写它在codebehind这不是I'm working on the styles of controls. I want to change the borderthickness of a control wh...

我工作的控件的样式。我想换一个控制了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.

阅读全文

相关推荐

最新文章