55 строки
2.5 KiB
XML
55 строки
2.5 KiB
XML
|
|
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
x:Class="Microsoft.Samples.Graphics.Transforms.AnimatedScaleTransformExample"
|
|
WindowTitle="Animated ScaleTransform Example"
|
|
Background="White">
|
|
|
|
<Border BorderBrush="LightGray" BorderThickness="2" Background="WhiteSmoke" Margin="10">
|
|
<StackPanel Margin="10">
|
|
<TextBlock Margin="0,10,0,0" Width="250">
|
|
The ScaleX and ScaleY properties of this ScaleTransform are each animated from 0 to 1.
|
|
</TextBlock>
|
|
<Border BorderBrush="Black" BorderThickness="1" Background="{StaticResource MyBlueGridBrushResource}"
|
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
|
<Canvas Width="250" Height="250">
|
|
<Rectangle
|
|
Height="50" Width="50" Fill="#CCCCCCFF" Stroke="Blue" StrokeThickness="2"
|
|
Canvas.Left="100" Canvas.Top="100">
|
|
<Rectangle.RenderTransform>
|
|
<ScaleTransform x:Name="MyAnimatedScaleTransform" CenterX="25" CenterY="25" ScaleX="1" ScaleY="1" />
|
|
</Rectangle.RenderTransform>
|
|
</Rectangle>
|
|
<Rectangle Height="50" Width="50" Stroke="#99000000"
|
|
StrokeDashArray="4,1" StrokeThickness="2"
|
|
Canvas.Left="100" Canvas.Top="100" />
|
|
</Canvas>
|
|
</Border>
|
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
|
|
Margin="10">
|
|
<Button Name="startButton" Margin="0,0,2,0">Start</Button>
|
|
<Button Name="stopButton">Stop</Button>
|
|
<StackPanel.Triggers>
|
|
<EventTrigger SourceName="startButton" RoutedEvent="Button.Click">
|
|
<BeginStoryboard Name="myBeginStoryboard">
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="MyAnimatedScaleTransform"
|
|
Storyboard.TargetProperty="ScaleX"
|
|
From="0" To="3" Duration="0:0:2" />
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="MyAnimatedScaleTransform"
|
|
Storyboard.TargetProperty="ScaleY"
|
|
From="0" To="3" Duration="0:0:2" />
|
|
</Storyboard>
|
|
</BeginStoryboard>
|
|
</EventTrigger>
|
|
<EventTrigger SourceName="stopButton" RoutedEvent="Button.Click">
|
|
<StopStoryboard BeginStoryboardName="myBeginStoryboard" />
|
|
</EventTrigger>
|
|
</StackPanel.Triggers>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Border>
|
|
</Page>
|