I'm using UWP and I'm trying to apply Color animation using Keyframes to a DropShadowPanel from the UWP Community Toolkit.
but I haven't been able to succeed so far I've been able to apply DoubleAnimation to BlurRadius Property and Opacity Property but everytime I try to apply Color animation my program breaks.
I also applied Color Animation to a Polygon Shape at my Canvas and it worked great, I'm using almost the same code, can somebody give me a hint please:
This is the code from my polygon it WORKS:
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ChristmasStarUpperPosition"
Storyboard.TargetProperty="(Polygon.Fill).(SolidColorBrush.Color)"
RepeatBehavior="Forever"
AutoReverse="True">
<LinearColorKeyFrame Value="Silver" KeyTime="0:0:5"/>
<LinearColorKeyFrame Value="LightGray" KeyTime="0:0:2"/>
<SplineColorKeyFrame Value="Gray" KeyTime="0:0:2.5" KeySpline="0.6,0.0 0.9,0.00"/>
<DiscreteColorKeyFrame Value="Blue" KeyTime="0:0:3"/>
<LinearColorKeyFrame Value="Blue" KeyTime="0:0:5"/>
<LinearColorKeyFrame Value="LightBlue" KeyTime="0:0:2"/>
<SplineColorKeyFrame Value="DeepSkyBlue" KeyTime="0:0:2.5" KeySpline="0.6,0.0 0.9,0.00"/>
<DiscreteColorKeyFrame Value="Goldenrod" KeyTime="0:0:3"/>
<LinearColorKeyFrame Value="Goldenrod" KeyTime="0:0:5"/>
</ColorAnimationUsingKeyFrames>
and this is the code I'm trying to apply to my DropShadowPanel this code makes mas program fail at xaml level.
<ColorAnimationUsingKeyFrames Storyboard.TargetName="ChristmasBonusStarUpperDropShadowPolygonColor"
Storyboard.TargetProperty="(DropShadowPanel.Color).(SolidColorBrush.Color)"
RepeatBehavior="Forever"
AutoReverse="True">
<LinearColorKeyFrame Value="Silver" KeyTime="0:0:5"/>
<LinearColorKeyFrame Value="LightGray" KeyTime="0:0:2"/>
<SplineColorKeyFrame Value="Gray" KeyTime="0:0:2.5" KeySpline="0.6,0.0 0.9,0.00"/>
<DiscreteColorKeyFrame Value="Blue" KeyTime="0:0:3"/>
<LinearColorKeyFrame Value="Blue" KeyTime="0:0:5"/>
<LinearColorKeyFrame Value="LightBlue" KeyTime="0:0:2"/>
<SplineColorKeyFrame Value="DeepSkyBlue" KeyTime="0:0:2.5" KeySpline="0.6,0.0 0.9,0.00"/>
<DiscreteColorKeyFrame Value="Goldenrod" KeyTime="0:0:3"/>
<LinearColorKeyFrame Value="Goldenrod" KeyTime="0:0:5"/>
</ColorAnimationUsingKeyFrames>
hopefully someone can help me out!!!
Thanks!!!
Although the
Colorproperty is a dependency property, it merely acts like a proxy that updates theColorof an innerDropShadow(see code below) that comes fromWindows.UI.Composition. A traditional XAML storyboard simply won't work.But what you want can be easily achieved by using the new color animation API (i.e.
CreateColorKeyFrameAnimation) from Composition. Here's an example for your particular case: