Skip to content

Visual Element Extensions

The Visual Element extensions provide various ways to animate different properties of a control.

Methods

Task<bool> ColorTo<TElement>(this TElement element, Expression<Func<TElement, Color>> start, Color end, uint rate = 16, uint length = 250, Easing easing = null)

Extends VisualElement with a new ColorTo method which provides a higher level approach for animating an elements color.

Properties

element: VisualElement to process

start: Expression

end: End color

rate: The time, in milliseconds, between frames

length: The number of milliseconds over which to interpolate the animation

easing: The easing function to use to transision in, out, or in and out of the animation

Task<bool> TransitionTo<TElement>(this TElement element, Expression<Func<TElement, double>> start, double end, uint rate = 16, uint length = 250, Easing easing = null)

Extends VisualElement with a new SizeTo method which provides a higher level approach for animating transitions.

Properties

element: The VisualElement to perform animation on

start: The animation starting point

end: The animation ending point

rate: The time, in milliseconds, between frames

length: The number of milliseconds over which to interpolate the animation

easing: The easing function to use to transision in, out, or in and out of the animation

Task<bool> TransitionTo<TElement>(this TElement element, string animationName, Action<double> callback, Func<double> start, double end, uint rate = 16, uint length = 250, Easing easing = null)
Task<bool> TransitionTo<TElement>(this TElement element, string animationName, Action<int> callback, Func<int> start, int end, uint rate = 16, uint length = 250, Easing easing = null)
Task<bool> PointTo<TElement>(this TElement element, Expression<Func<TElement, Point>> start, Point end, uint rate = 16, uint length = 250, Easing easing = null)

Extends VisualElement with a new PointTo method which provides a higher level method for animating Points

Properties

element: The VisualElement to perform animation on

start: Start in point

end: Ending point

rate: The time, in milliseconds, between frames

length: The number of milliseconds over which to interpolate the animation

easing: The easing function to use to transision in, out, or in and out of the animation

Task<bool> ThicknessTo<TElement>(this TElement element, Expression<Func<TElement, Thickness>> start, Thickness end, uint rate = 16, uint length = 250, Easing easing = null)

Extends VisualElement with a new ThicknessTo method which provides a higher level approach for animating an elements Thickness.

element: The VisualElement to perform animation on

start: Starting thickness

end: Ending thickness

rate: The time, in milliseconds, between frames

length: The number of milliseconds over which to interpolate the animation

easing: The easing function to use to transision in, out, or in and out of the animation

Task<bool> SizeTo<TElement>(this TElement element, Expression<Func<TElement, Size>> start, Size end, uint rate = 16, uint length = 250, Easing easing = null)

Extends VisualElement with a new SizeTo method which provides a higher level approach for animating an elements Size.

element: The VisualElement to perform animation on

start: The start size

end: The end size

rate: The time, in milliseconds, between frames

length: The number of milliseconds over which to interpolate the animation

easing: The easing function to use to transision in, out, or in and out of the animation

Example Usage

// Animate the angle of rotation of the gradient on a control
control.TransitionTo(c => c.GradientRotationAngle, rng.Next(-360, 360), length: runtimeLength, easing: Easing.CubicInOut),

// Animate the change in color on the control
control.ColorTo(x => x.GradientStartColor, startColor, length: runtimeLength, easing: Easing.CubicInOut),