<!-- OpacityAnimationExample.xaml
This example shows how to animate the opacity of objects,
making them fade in and out of view. -->
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="Opacity Animation Example" Background="White">
<StackPanel Margin="20">
<!-- Clicking this button animates its opacity. -->
<Button Name="opacityAnimatedButton">
A Button
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="opacityAnimatedButton"
Storyboard.TargetProperty="(Button.Opacity)"
From="1" To="0" Duration="0:0:5" AutoReverse="True" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<!-- Clicking this button animates the opacity of the brush
used to paint its background. -->
<Button>
A Button
<Button.Background>
<SolidColorBrush x:Name="MyAnimatedBrush" Color="Orange" />
</Button.Background>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyAnimatedBrush"
Storyboard.TargetProperty="(Brush.Opacity)"
From="1" To="0" Duration="0:0:5" AutoReverse="True" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</StackPanel>
</Page>