开发者

Referring to a brush resource in a VisualState ColorAnimation

I'm trying to style the Calendar control and need 开发者_StackOverflow中文版the buttons to adopt the colors we already have defined as named resources. But the storyboards require colors in the ColorAnimation, and I'm not sure how to use a brush there.

For example, I need to turn this

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

Into something like this:

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

How do I do this?


I define two resources, the Brush dependent on the Color:

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

This is, in fact, the same technique used elsewhere in WPF, such as in the SystemColors class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜