Reputation: 2430
I'm looking for a way to set a Property
after it was animated, in pure xaml
.
Msdn has an example of how to do that in xaml
+ codebehind
:
XAML:
<Button
Content="Animate and Then Set Example 1">
<Button.Background>
<SolidColorBrush x:Name="Button1BackgroundBrush"
Color="Red" />
</Button.Background>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="Button1BackgroundBrush"
Storyboard.TargetProperty="Color"
From="Red" To="Yellow" Duration="0:0:5"
FillBehavior="HoldEnd"
Completed="setButton1BackgroundBrushColor" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
C#:
private void setButton1BackgroundBrushColor(object sender, EventArgs e)
{
Button1BackgroundBrush.Color = Colors.Blue;
}
Upvotes: 1
Views: 682
Reputation: 10339
In this particular case you could add another ColorAnimation
and delay it appropriately via its BeginTime
property, like so:
<Storyboard>
<ColorAnimation
Storyboard.TargetName="Button1BackgroundBrush"
Storyboard.TargetProperty="Color"
From="Red" To="Yellow" Duration="0:0:5" />
<ColorAnimation
Storyboard.TargetName="Button1BackgroundBrush"
Storyboard.TargetProperty="Color"
To="Blue" Duration="0"
BeginTime="0:0:5" />
</Storyboard>
In more general case, depending on the property type, you could use appropriate animation, if one exists, in analogous way.
Upvotes: 1