Timeline.Completed 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當這個時刻表完全結束播放時會發生:它不會再進入其作用期。
public:
event EventHandler ^ Completed;
public event EventHandler Completed;
member this.Completed : EventHandler
Public Custom Event Completed As EventHandler
事件類型
範例
在下列範例中,兩個 物件是用來建立兩 Storyboard 個影像之間的動畫轉換,這些影像是使用 ImageSource 物件儲存,並使用 Image 控制項顯示。 一個分鏡腳本會壓縮影像控制項,直到它消失為止。 完成之後,舊的 ImageSource 會與其他 ImageSource 交換,而第二個腳本會展開影像控制項,直到再次完整調整大小為止。
<!-- TimelineCompletedExample.xaml
This example creates an animated transition between
two images. When the user clicks the Start Transition button,
a storyboard shrinks an image until it disappears.
The Completed event is used to notify the class when this
storyboard has completed. The code behind file handles
this event by swapping the image and making it visible again.
-->
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SDKSample.TimelineCompletedExample"
WindowTitle="Timeline Completed Example"
Loaded="exampleLoaded">
<Page.Resources>
<!-- A simple picture of a rectangle. -->
<DrawingImage x:Key="RectangleDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,100,100" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="Orange">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="25,25,50,50" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<!-- A simple picture of a cirlce. -->
<DrawingImage x:Key="CircleDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,100,100" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<EllipseGeometry Center="50,50" RadiusX="25" RadiusY="25" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<RadialGradientBrush GradientOrigin="0.75,0.25" Center="0.75,0.25">
<GradientStop Offset="0.0" Color="White" />
<GradientStop Offset="1.0" Color="LimeGreen" />
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<!-- Define the storyboard that enlarges the image.
This storyboard is applied using code when
ZoomOutStoryboard completes. -->
<Storyboard x:Key="ZoomInStoryboardResource">
<DoubleAnimation
Storyboard.TargetName="AnimatedImageScaleTranform"
Storyboard.TargetProperty="ScaleX"
Duration="0:0:5" To="1" />
<DoubleAnimation
Storyboard.TargetName="AnimatedImageScaleTranform"
Storyboard.TargetProperty="ScaleY"
Duration="0:0:5" To="1" />
</Storyboard>
</Page.Resources>
<StackPanel Margin="20" >
<Border
BorderBrush="Gray" BorderThickness="2"
HorizontalAlignment="Center" VerticalAlignment="Center">
<!-- Displays the current ImageSource. -->
<Image
Name="AnimatedImage"
Width="200" Height="200"
RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<ScaleTransform x:Name="AnimatedImageScaleTranform"
ScaleX="1" ScaleY="1" />
</Image.RenderTransform>
</Image>
</Border>
<!-- This StackPanel contains buttons that control the storyboard. -->
<StackPanel Orientation="Horizontal" Margin="0,30,0,0">
<Button Name="BeginButton">Start Transition</Button>
<Button Name="SkipToFillButton">Skip To Fill</Button>
<Button Name="StopButton">Stop</Button>
<StackPanel.Triggers>
<!-- Begin the storyboard that shrinks the image. After the storyboard
completes, -->
<EventTrigger RoutedEvent="Button.Click" SourceName="BeginButton">
<BeginStoryboard Name="ZoomOutBeginStoryboard">
<Storyboard x:Name="ZoomOutStoryboard"
Completed="zoomOutStoryboardCompleted" FillBehavior="Stop">
<DoubleAnimation
Storyboard.TargetName="AnimatedImageScaleTranform"
Storyboard.TargetProperty="ScaleX"
Duration="0:0:5" To="0" FillBehavior="Stop" />
<DoubleAnimation
Storyboard.TargetName="AnimatedImageScaleTranform"
Storyboard.TargetProperty="ScaleY"
Duration="0:0:5" To="0" FillBehavior="Stop" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<!-- Advances ZoomOutStoryboard to its fill period.
This action triggers the Completed event. -->
<EventTrigger RoutedEvent="Button.Click" SourceName="SkipToFillButton">
<SkipStoryboardToFill BeginStoryboardName="ZoomOutBeginStoryboard" />
</EventTrigger>
<!-- Stops the storyboard. This action does not
trigger the completed event. -->
<EventTrigger RoutedEvent="Button.Click" SourceName="StopButton">
<StopStoryboard BeginStoryboardName="ZoomOutBeginStoryboard" />
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
</StackPanel>
</Page>
備註
如果此時間軸是時間軸樹狀結構的根時間軸,則它已完成在其使用期間結束之後播放 (包括重複) 及其所有子系都已到達其使用期間結尾。 如果此時間軸是子時程表,當其所屬時程表的根時程表到達其使用期間結尾,且其所有子時間軸都已完成播放時,就會將其視為完全完成播放。
停止時間軸不會觸發其已完成的事件,但會略過其填滿期間。
Object事件處理常式的 EventHandler 參數是時程表的 Clock 。
雖然這個事件處理常式似乎與時間軸相關聯,但它實際上會向為此時程表建立的 Clock 註冊。 如需詳細資訊,請參閱 計時事件概觀。