ColorAnimation cannot be used to animate property Background due to incompatible type

When you try to animate the background color of a border element you get above error.

Here is your storyboard

<Storyboard x:Name=”TimerColorAnimation”>
            <ColorAnimation Storyboard.TargetName=”TimerBorder” Storyboard.TargetProperty=”Background” From=”Green” To=”Yellow” AutoReverse=”True” RepeatBehavior=”Forever”></ColorAnimation>

the issue here is that you can not animate the border background like this instead you have to color animation with key frames.

Here is an example of same

<UserControl x:Class=”AnimationsLight.DigitalClock”
    d:DesignHeight=”300″ d:DesignWidth=”400″>
        <Style TargetType=”TextBlock”>
            <Setter Property=”FontFamily” Value=”Verdana” />
            <Setter Property=”FontSize” Value=”30″/>
        <Storyboard x:Name=”TimerColorAnimation”>
            <ColorAnimationUsingKeyFrames Storyboard.TargetName=”TimerBorder” Storyboard.TargetProperty=”(Border.Background).(SolidColorBrush.Color)” AutoReverse=”True” RepeatBehavior=”Forever”>
                <EasingColorKeyFrame KeyTime=”00:00:01″ Value=”LightGreen”/>
                <EasingColorKeyFrame KeyTime=”00:00:02″ Value=”Pink”/>
                <EasingColorKeyFrame KeyTime=”00:00:03″ Value=”LightPink”/>
                <EasingColorKeyFrame KeyTime=”00:00:04″ Value=”Gray”/>
                <EasingColorKeyFrame KeyTime=”00:00:05″ Value=”LightGray”/>
    <Grid x:Name=”LayoutRoot” Background=”White”>
            <Border x:Name=”TimerBorder” Width=”200″ Height=”100″ BorderBrush=”#FF000000″ Background=”Green” CornerRadius=”3,3,3,3″>
                <StackPanel Orientation=”Horizontal” VerticalAlignment=”Center” HorizontalAlignment=”Center”>
                    <TextBlock x:Name=”Hr”>00</TextBlock>
                    <TextBlock x:Name=”Min”>00</TextBlock>
                    <TextBlock x:Name=”Sec”>00</TextBlock>


The important part here is the how you set the Storyboard.TargetProperty

see the value is


if you will simply set it to Storyboard.TargetProperty=”Background”  the issue will remain same and you will get below error

ColorAnimationUsingKeyFrames cannot be used to animate property Background due to incompatible type. So change the storyboard TargetProperty to (Border.Background).(SolidColorBrush.Color)”  and it will work.


One thought on “ColorAnimation cannot be used to animate property Background due to incompatible type

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s