diff --git a/src/Avalonia.Visuals/Animation/CompositeTransition.cs b/src/Avalonia.Visuals/Animation/CompositeTransition.cs new file mode 100644 index 0000000000..62ed9d5bc1 --- /dev/null +++ b/src/Avalonia.Visuals/Animation/CompositeTransition.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Avalonia.Metadata; + +namespace Avalonia.Animation +{ + /// + /// Defines a composite transition that can be used to combine multiple transitions into one. + /// + /// + /// + /// Instantiate the in XAML and initialize the + /// property in order to have many animations triggered at once. + /// For example, you can combine and . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// ]]> + /// + /// + /// + public class CompositeTransition : IPageTransition + { + /// + /// Gets or sets the transitions to be executed. Can be defined from XAML. + /// + [Content] + public List Transitions { get; set; } = new List(); + + /// + /// Starts the animation. + /// + /// + /// The control that is being transitioned away from. May be null. + /// + /// + /// The control that is being transitioned to. May be null. + /// + /// + /// Defines the direction of the transition. + /// + /// + /// A that tracks the progress of the animation. + /// + public Task Start(Visual from, Visual to, bool forward) + { + var transitionTasks = Transitions + .Select(transition => transition.Start(from, to, forward)) + .ToList(); + return Task.WhenAll(transitionTasks); + } + } +}