1

我似乎无法使用ColorAnimation. 我已经查看了大约 5 种不同的方法来完成不同的 SO 答案和网页,但似乎没有一个有效。我错过了什么?

<Border.Style>
    <Style>
        <Style.Triggers>
            <Trigger Property="Border.IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Duration="0:0:0.15" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#f0f0f0" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
            </Trigger>
        </Style.Triggers>
    </Style>
</Border.Style>
4

1 回答 1

2

Probably you have set the Border.Background directly and not in Style. Then this will not work because of Dependency Property Value Precedence. You can't change a local value in a Style.

于 2013-05-08T10:00:15.730 回答