C
Join ServerC#
help
ColorAnimation using Color and not Brushes [Answered]
Zzonedetec10/17/2022
Hello my friends,
I found this code on the internet :
This permits to do a really nice color animation from blue to red in the window. I want exactly this but sadly, because I am using a "GradientStop" as a container for my color it won't work, because GradientStop have a Color property and not a Brush property.
So how can I fix this code so it works on my gradientStop element ?
Thank you!
I found this code on the internet :
private void button1_Click(object sender, RoutedEventArgs e)
{
ColorAnimation ca = new ColorAnimation(Colors.Blue, new Duration(TimeSpan.FromSeconds(4)));
this.Background = new SolidColorBrush(Colors.Red);
this.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
}
This permits to do a really nice color animation from blue to red in the window. I want exactly this but sadly, because I am using a "GradientStop" as a container for my color it won't work, because GradientStop have a Color property and not a Brush property.
So how can I fix this code so it works on my gradientStop element ?
Thank you!
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#00000000" Offset="0"/>
<GradientStop x:Name="GameCanvas_color" Color="#66FF0000" Offset="0.964"/> <!-- on this! -->
</LinearGradientBrush>
</Grid.Background>
Zzonedetec10/17/2022
This is what I have done so far :
For the moment there is no animation
// animation couleur verte
ColorAnimation ca = new ColorAnimation(Colors.Red, new Duration(TimeSpan.FromSeconds(4)));
GameCanvas_color.Color = Colors.Blue;
GameCanvas_color.BeginAnimation(SolidColorBrush.ColorProperty, ca);
For the moment there is no animation
Zzonedetec10/17/2022
I'm sure 90% it have something to do with SolidColorBrush.ColorProperty.
Zzonedetec10/17/2022
I've done it ^^'
ColorAnimation ca = new ColorAnimation(Colors.Red, new Duration(TimeSpan.FromSeconds(4)));
GameCanvas_color.Color = Colors.Blue;
GameCanvas_color.BeginAnimation(GradientStop.ColorProperty, ca);
AAccord10/17/2022
✅ This post has been marked as answered!