【问题标题】:Change Background on Border using ColorAnimation使用 ColorAnimation 更改边框上的背景
【发布时间】:2013-05-08 09:49:32
【问题描述】:

我似乎无法使用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>

【问题讨论】:

  • 我已经测试过了,它正在工作。
  • 它为我崩溃了...

标签: wpf xaml styles


【解决方案1】:

可能您直接设置了Border.Background,而不是Style。那么由于Dependency Property Value Precedence,这将不起作用。您不能更改样式中的本地值。

【讨论】:

  • 在样式中使用 Setter 设置边框背景。
猜你喜欢
  • 2012-04-02
  • 1970-01-01
  • 2013-10-15
  • 2016-08-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-23
  • 1970-01-01
相关资源
最近更新 更多