Delen via


TransitionCollection Class

Definition

Represents a collection of Transition objects. Each Transition object represents a different theme transition, part of the Windows Runtime animation library.

public ref class TransitionCollection sealed : IIterable<Transition ^>, IVector<Transition ^>
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class TransitionCollection final : IIterable<Transition>, IVector<Transition>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class TransitionCollection final : IIterable<Transition>, IVector<Transition>
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class TransitionCollection : IEnumerable<Transition>, IList<Transition>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class TransitionCollection : IEnumerable<Transition>, IList<Transition>
Public NotInheritable Class TransitionCollection
Implements IEnumerable(Of Transition), IList(Of Transition)
<TransitionCollection>
    oneOrMoreTransitions
</TransitionCollection>
Inheritance
Object Platform::Object IInspectable TransitionCollection
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

This example shows the XAML syntax for setting a TransitionCollection object element as part of setting the UIElement.Transitions property inline.

<Button Content="EntranceThemeTransition Button">
    <Button.Transitions>
        <TransitionCollection>
            
            <!-- This transition just uses the default behavior which is to
                 have the button animate into view from the right. You can
                 make it start from anywhere on the right by using the
                 FromHorizontalOffset property. If you'd rather see a vertical
                 animation, use the FromVerticalOffset property. -->
            <EntranceThemeTransition />
        </TransitionCollection>
    </Button.Transitions>
</Button>
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
    <Grid.Resources>
        <Style x:Key="DefaultButtonStyle" TargetType="Button">
            <Setter Property="Transitions">
                <Setter.Value>
                    <TransitionCollection>
                        <EntranceThemeTransition/>
                    </TransitionCollection>
                </Setter.Value>
            </Setter>
        </Style>
    </Grid.Resources>

    <Button Style="{StaticResource DefaultButtonStyle}" 
            Content="EntranceThemeTransition style applied" />

</Grid>

Remarks

TransitionCollection is used as the value type for these properties:

Note

Prior to Windows 10, version 1809 (SDK 17763), the XAML syntax for properties that have a TransitionCollection value requires that you declare an explicit TransitionCollection object element as the value, and then provide object elements as child elements of TransitionCollection for each of the transition animations you want to use. In Windows 10, version 1809 (SDK 17763) or later, TransitionCollection supports the implicit collection usage, so you can omit the collection object element. For more info on implicit collections and XAML, see XAML syntax guide.

Transition animations are preconfigured animations from the Windows Runtime animation library. Transition animations run automatically upon the conditions that the transition animation is associated with, using the property owner where the TransitionCollection is set as the target. The properties being animated vary depending on which transition you use.

VisualStateGroup.Transitions does not use the TransitionCollection type. VisualStateGroup.Transitions uses a built-in collection(list or vector) of VisualTransition objects.

Enumerating the collection in C# or Microsoft Visual Basic

A TransitionCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<Transition> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a Transition constraint.

Constructors

TransitionCollection()

Initializes a new instance of the TransitionCollection class.

Properties

Size

Gets the size (count) of the collection.

Methods

Append(Transition)

Adds a new item to the collection.

Clear()

Removes all items from the collection.

First()

Returns the iterator for iteration over the items in the collection.

GetAt(UInt32)

Returns the item located at the specified index.

GetMany(UInt32, Transition[])

Retrieves multiple elements in a single pass through the iterator.

GetView()

Gets an immutable view into the collection.

IndexOf(Transition, UInt32)

Retrieves the index of the specified item.

InsertAt(UInt32, Transition)

Inserts the specified item at the specified index.

RemoveAt(UInt32)

Removes the item at the specified index.

RemoveAtEnd()

Removes the last item in the collection.

ReplaceAll(Transition[])

Initially clears the collection, then inserts the provided array as new items.

SetAt(UInt32, Transition)

Sets the value at the specified index to the Transition value specified.

Applies to

See also