Class Animation
- Namespace
- Icy.Animations
- Assembly
- IcyUI.dll
Represents a single running (or stopped) instance of a Timeline applied to a target object's property.
public class Animation
- Inheritance
-
Animation
- Inherited Members
- Extension Methods
Remarks
Drives its target property through the Animation precedence tier (see SetTierValue(object, PropertyValuePrecedence, object?)) rather than assigning the property directly, so a local assignment always still wins, and clearing this contribution (Stop()) cleanly reverts to whatever the style/visual-state/local value was.
Ticked once per frame by UpdateAnimations(TimeSpan) (called from Render()) once Start() registers it - construct via Animate(UIElement, Timeline) for the common case of animating a UIElement property.
Constructors
Animation(object, Timeline)
Initializes a new instance of the Animation class for timeline applied
to target.
public Animation(object target, Timeline timeline)
Parameters
targetobjectThe object to animate. Must have a property named TargetProperty registered with PropertyRegistry (e.g. via RegisterReferenceAttribute).
timelineTimelineThe animation to play.
Remarks
Converts and caches timeline's keyframe values exactly once here, against the target
property's real type - it does not read Keyframes live on every tick.
Consequently, mutating a shared Timeline (e.g. calling
AddKeyframe(float, object?)) after an Animation has
already been constructed from it - running or not - no longer affects that instance, which keeps its own
frozen, converted copy. This matches Timeline being "a reusable description,
not a running animation" (see its own remarks).
Exceptions
- ArgumentException
target's type has no property named TargetProperty registered.- InvalidOperationException
The targeted property is marked with NonAnimatableAttribute.
Properties
IsPaused
Gets a value indicating whether this animation is running but temporarily suspended via Pause().
public bool IsPaused { get; }
Property Value
IsRunning
Gets a value indicating whether this animation is currently ticking (running and not Pause()d).
public bool IsRunning { get; }
Property Value
Target
Gets the object this animation targets.
public object Target { get; }
Property Value
Timeline
Gets the Timeline this animation plays.
public Timeline Timeline { get; }
Property Value
Methods
Pause()
Suspends ticking this animation in place, without losing its current position. Resume with Resume().
public void Pause()
Resume()
Resumes ticking a Pause()d animation from where it left off. A no-op if not currently running.
public void Resume()
Start()
Starts (or restarts, if not currently running) this animation from the beginning.
public void Start()
Remarks
A no-op if the animation is already running - call Stop() first to restart mid-flight.
Stop()
Stops this animation immediately (whether running or already completed) and clears its contribution to the target property's Animation tier, reverting to whatever the next-highest precedence tier (or the local/default value) currently provides.
public void Stop()
Events
Completed
Occurs when this animation finishes playing every configured repeat on its own. Never raised by Stop().
public event EventHandler? Completed