■ ScalarKeyFrameAnimation 클래스의 Direction/IterationBehavior/Duration 속성을 사용하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
using System; using System.Numerics; using Microsoft.UI; using Microsoft.UI.Composition; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; // ... TextBlock textBlock; // ... Visual textBlockVisual = ElementCompositionPreview.GetElementVisual(textBlock); Compositor compositor = textBlockVisual.Compositor; PointLight pointLight = compositor.CreatePointLight(); pointLight.CoordinateSpace = textBlockVisual; pointLight.Offset = new Vector3(0, (float)this.textBlock.ActualHeight / 2, (float)this.textBlock.FontSize); pointLight.Color = Colors.White; ScalarKeyFrameAnimation scalarKeyFrameAnimation = compositor.CreateScalarKeyFrameAnimation(); scalarKeyFrameAnimation.InsertKeyFrame(1, (float)textBlock.ActualWidth); scalarKeyFrameAnimation.Direction = AnimationDirection.Alternate; scalarKeyFrameAnimation.IterationBehavior = AnimationIterationBehavior.Forever; scalarKeyFrameAnimation.Duration = TimeSpan.FromSeconds(2); pointLight.StartAnimation("Offset.X", scalarKeyFrameAnimation); |