4
4
5
5
#nullable enable
6
6
7
+ using System ;
7
8
using Windows . UI . Composition ;
8
9
using Windows . UI . Xaml ;
9
10
using static Microsoft . Toolkit . Uwp . UI . Animations . AnimationExtensions ;
@@ -14,9 +15,35 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
14
15
/// A base model representing a typed animation that can be used as an implicit composition animation.
15
16
/// </summary>
16
17
/// <inheritdoc cref="Animation{TValue, TKeyFrame}"/>
17
- public abstract class ImplicitAnimation < TValue , TKeyFrame > : Animation < TValue , TKeyFrame > , IImplicitTimeline
18
+ public abstract class ImplicitAnimation < TValue , TKeyFrame > : Animation < TValue , TKeyFrame > , IImplicitTimeline , IInternalImplicitAnimation
18
19
where TKeyFrame : unmanaged
19
20
{
21
+ /// <inheritdoc cref="IInternalImplicitAnimation.AnimationPropertyChanged"/>
22
+ private event EventHandler ? AnimationPropertyChanged ;
23
+
24
+ /// <summary>
25
+ /// Initializes a new instance of the <see cref="ImplicitAnimation{TValue, TKeyFrame}"/> class.
26
+ /// </summary>
27
+ protected ImplicitAnimation ( )
28
+ {
29
+ RegisterPropertyChangedCallback ( DelayProperty , RaiseAnimationPropertyChanged ) ;
30
+ RegisterPropertyChangedCallback ( DurationProperty , RaiseAnimationPropertyChanged ) ;
31
+ RegisterPropertyChangedCallback ( EasingTypeProperty , RaiseAnimationPropertyChanged ) ;
32
+ RegisterPropertyChangedCallback ( EasingModeProperty , RaiseAnimationPropertyChanged ) ;
33
+ RegisterPropertyChangedCallback ( RepeatProperty , RaiseAnimationPropertyChanged ) ;
34
+ RegisterPropertyChangedCallback ( DelayBehaviorProperty , RaiseAnimationPropertyChanged ) ;
35
+ RegisterPropertyChangedCallback ( ToProperty , RaiseAnimationPropertyChanged ) ;
36
+ RegisterPropertyChangedCallback ( FromProperty , RaiseAnimationPropertyChanged ) ;
37
+ RegisterPropertyChangedCallback ( KeyFramesProperty , RaiseAnimationPropertyChanged ) ;
38
+ }
39
+
40
+ /// <inheritdoc/>
41
+ event EventHandler ? IInternalImplicitAnimation . AnimationPropertyChanged
42
+ {
43
+ add => AnimationPropertyChanged += value ;
44
+ remove => AnimationPropertyChanged -= value ;
45
+ }
46
+
20
47
/// <summary>
21
48
/// Gets or sets the optional implicit target for the animation. This can act as a trigger property for the animation.
22
49
/// </summary>
@@ -67,5 +94,15 @@ public CompositionAnimation GetAnimation(UIElement element, out string? target)
67
94
68
95
return builder . GetAnimation ( element . GetVisual ( ) , out _ ) ;
69
96
}
97
+
98
+ /// <summary>
99
+ /// Raises <see cref="AnimationPropertyChanged"/> event.
100
+ /// </summary>
101
+ /// <param name="sender">The instance raising the event.</param>
102
+ /// <param name="property">The <see cref="DependencyProperty"/> that was changed.</param>
103
+ private void RaiseAnimationPropertyChanged ( DependencyObject sender , DependencyProperty property )
104
+ {
105
+ AnimationPropertyChanged ? . Invoke ( this , EventArgs . Empty ) ;
106
+ }
70
107
}
71
108
}
0 commit comments