[Rectangle] Comment y réaliser une Color Animation ?
bonjour à tous,
j'ai réussi récemment à animer le background color d'un boutton comme ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<LinearGradientBrush x:Key="brushFire" StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="Red" Offset="0.5" />
</LinearGradientBrush>
<Style x:Key="buttonFire" TargetType="{x:Type Button}">
<Style.Triggers>
<EventTrigger RoutedEvent="Button.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Background.GradientStops[1].Color">
<ColorAnimation From="Black" To="Red" Duration="0:0:2"
AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style> |
Tout marche parfaitement et je voulais faire la même chose mais avec un rectangle donc j'ai modifié en conséquence :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<Style x:Key="fourStyle" TargetType="{x:Type Rectangle}">
<Setter Property="Width" Value="94" />
<Setter Property="Height" Value="84" />
<Setter Property="Stroke" Value="Black" />
<Setter Property="StrokeThickness" Value="2" />
<Setter Property="RadiusX" Value="10" />
<Setter Property="RadiusY" Value="10" />
<Style.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Fill.LinearGradientBrush.GradientStop[1].Color">
<ColorAnimation From="Black" To="Red" Duration="0:0:2"
AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style> |
Seulement, là, il me renvoie une erreur spécifiant que la propriété "Fill.LinearGradientBrush.GradientStop[1].Color" est inaccessible. :(