방법: 활성 기간이 끝난 Timeline의 FillBehavior 지정
이 예제는 애니메이션 속성의 비활성 Timeline에 대해 FillBehavior를 지정하는 방법을 보여 줍니다.
예제
Timeline의 FillBehavior 속성은 애니메이션 효과가 적용되지 않을 때, 즉 Timeline이 비활성화이지만 부모인 Timeline이 활성 또는 보류 기간 내에 있을 때 애니메이션 속성의 값에 무슨 일이 일어나는지를 결정합니다. 예를 들어 애니메이션이 종료된 후 애니메이션 속성이 끝 값에 유지되거나 애니메이션이 시작되기 전의 값으로 되돌려지나요?
다음 예제에서는 DoubleAnimation을 사용하여 두 사각형의 Width에 애니메이션 효과를 적용합니다. 각 사각형은 서로 다른 Timeline 개체를 사용합니다.
한 Timeline의 FillBehavior는 Stop으로 설정되어 있으며, 이로 인해 Timeline이 종료되면 사각형의 너비가 애니메이션이 적용되지 않은 값으로 되돌려집니다. 다른 Timeline의 FillBehavior는 HoldEnd이며, 이로 인해 Timeline이 종료되면 너비가 끝 값으로 남아 있습니다.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<StackPanel Margin="20">
<Border Background="#99FFFFFF">
<TextBlock Margin="20">
This example shows how the FillBehavior property determines how an animation behaves
after it reaches the end of its duration.
</TextBlock>
</Border>
<TextBlock>FillBehavior="Deactivate"</TextBlock>
<Rectangle Name="deactiveAnimationRectangle" Width="20" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" >
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<!-- The animated rectangle's width reverts back to its non-animated value
after the animation ends. -->
<DoubleAnimation
Storyboard.TargetName="deactiveAnimationRectangle"
Storyboard.TargetProperty="Width"
From="100" To="400" Duration="0:0:2" FillBehavior="Stop" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
<TextBlock Margin="0,20,0,0">FillBehavior="HoldEnd" </TextBlock>
<Rectangle Name="holdEndAnimationRectangle" Width="20" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" >
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<!-- The animated rectangle's width remains at its end value after the
animation ends. -->
<DoubleAnimation Storyboard.TargetName="holdEndAnimationRectangle"
Storyboard.TargetProperty="Width"
From="100" To="400" Duration="0:0:2" FillBehavior="HoldEnd" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</StackPanel>
</Page>
전체 샘플은 애니메이션 예제 갤러리를 참조하세요.
참고 항목
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET Desktop feedback
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기