<Window x:Class="CombineTransforms"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Combining Transforms" Height="330" Width="300">
<Viewbox Stretch="Uniform">
<StackPanel>
<TextBlock HorizontalAlignment="Center" Margin="10,10,10,0"
TextWrapping="Wrap" FontSize="14" FontWeight="Bold"
Text="Animation of Combining Transform" />
<Border Margin="10" BorderBrush="Black" BorderThickness="1"
HorizontalAlignment="Left">
<Canvas ClipToBounds="True" Width="340" Height="320">
<Ellipse Canvas.Left="165" Canvas.Top="145"
Width="10" Height="10" Fill="Red" />
<Rectangle Canvas.Left="120" Canvas.Top="100"
Width="100" Height="100" Fill="LightCoral" Opacity="0.5"
Stroke="Black" StrokeThickness="2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="scale"
CenterX="50" CenterY="50" />
<RotateTransform x:Name="rotate"
CenterX="50" CenterY="50" />
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever"
AutoReverse="True">
<DoubleAnimation
Storyboard.TargetName="scale"
Storyboard.TargetProperty="ScaleX" From="0" To="3"
Duration="0:0:5" />
<DoubleAnimation
Storyboard.TargetName="scale"
Storyboard.TargetProperty="ScaleY" From="0" To="3"
Duration="0:0:5" />
<DoubleAnimation
Storyboard.TargetName="rotate"
Storyboard.TargetProperty="Angle" From="0" To="360"
Duration="0:0:5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
</Canvas>
</Border>
</StackPanel>
</Viewbox>
</Window>
|