views:

13

answers:

1

I'm trying to style the Calendar control and need 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?

+1  A: 

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.

HTH,
Kent

Kent Boogaart
Thanks I knew it was something simple. I need more sleep.
dex3703