Thursday, October 25, 2012

Windows Phone Backgound Color Animation

In Silverlight for Windows Phone you can't animate a Brush so you can't animate the Background of a control.

However, you can use the ColorAnimation class to animate the color of a Brush.

The following XAML shows an example:
<UserControl.Resources>
    <Storyboard x:FieldModifier="private" x:Name="SBStartAnimation"> 
        <ColorAnimation Storyboard.TargetName="BShade" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" From="#00000000" To="#aa000000" Duration="0:0:0.150" /> 
    </Storyboard> 
</UserControl.Resources>

<Border x:FieldModifier="private" x:Name="BShade" Background="#aa000000" /> 
The BShade object must have it's Background property initialized.

No comments:

Post a Comment