【问题标题】:Referring to a brush resource in a VisualState ColorAnimation在 VisualState ColorAnimation 中引用画笔资源
【发布时间】:2010-08-02 21:34:40
【问题描述】:

我正在尝试设置日历控件的样式,并且需要按钮采用我们已经定义为命名资源的颜色。但是故事板需要 ColorAnimation 中的颜色,我不知道如何在那里使用画笔。

比如我需要转这个

<VisualState x:Name="MouseOver">
 <Storyboard>
  <ColorAnimation Duration="00:00:00" Storyboard.TargetName="TextColor" Storyboard.TargetProperty="Color" To="#FF73A9D8"/>
 </Storyboard>

变成这样:

 <ColorAnimation Duration="00:00:00" Storyboard.TargetName="TextColor" Storyboard.TargetProperty="Color" To="{StaticResource ForegroundBrush}"/>

我该怎么做?

【问题讨论】:

    标签: wpf resources colors visualstatemanager brush


    【解决方案1】:

    我定义了两个资源,Brush 依赖于Color

    <Color x:Key="ForegroundColor">#whatever</Color>
    <SolidColorBrush x:Key="ForegroundBrush" Color="{StaticResource ForegroundColor}"/>
    

    事实上,这与 WPF 其他地方使用的技术相同,例如在 SystemColors 类中。

    【讨论】:

    • 谢谢,我知道这很简单。我需要更多的睡眠。
    猜你喜欢
    • 2011-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    相关资源
    最近更新 更多