Share via


TransitionCollection 類別

定義

表示 Transition 物件的集合。 每個 Transition 物件都代表不同的主題轉換,這是 Windows 執行階段 動畫庫的一部分。

public ref class TransitionCollection sealed : IIterable<Transition ^>, IVector<Transition ^>
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 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.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 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>
Public NotInheritable Class TransitionCollection
Implements IEnumerable(Of Transition), IList(Of Transition)
<TransitionCollection>
    oneOrMoreTransitions
</TransitionCollection>
繼承
Object Platform::Object IInspectable TransitionCollection
屬性
實作

範例

此範例顯示將 TransitionCollection 物件項目設定為內嵌 UIElement.Transitions 屬性的一部分的 XAML 語法。

<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>

備註

TransitionCollection 會作為這些屬性的值類型:

注意

在 Windows 10 版本 1809 (SDK 17763) 之前,具有 TransitionCollection 值之屬性的 XAML 語法需要您將明確的 TransitionCollection 物件專案宣告為值,然後針對您想要使用的每個轉換動畫,提供對象元素作為 TransitionCollection 的子元素。 在 Windows 10 版本 1809 (SDK 17763) 或更新版本中,TransitionCollection 支援隱含集合使用方式,因此您可以省略集合物件專案。 如需隱含集合和 XAML 的詳細資訊,請參閱 XAML 語法指南

轉換動畫是從 Windows 執行階段 動畫庫預先設定的動畫。 轉換動畫會在轉換動畫與相關聯的條件上自動執行,並使用 TransitionCollection 設定為目標的屬性擁有者。 動畫的屬性會根據您使用的轉換而有所不同。

VisualStateGroup.Transitions 不會使用 TransitionCollection 類型。 VisualStateGroup.Transitions 使用 VisualTransition 物件的內建集合 (列表或向量) 。

列舉 C# 或 Microsoft Visual Basic 中的集合

TransitionCollection 是可列舉的,因此您可以使用 C# 中的 foreach 等語言特定語法來列舉集合中的專案。 編譯程式會為您執行型別轉換,而且您不需要明確地轉換成 IEnumerable<Transition> 。 如果您需要明確轉換,例如,如果您想要呼叫 GetEnumerator,請使用 Transition 條件約束轉換成 IEnumerable

建構函式

TransitionCollection()

初始化 TransitionCollection 類別的新實例。

屬性

Size

取得集合的大小 (計數) 。

方法

Append(Transition)

將新項目加入至集合中。

Clear()

移除集合的所有項目。

First()

傳回反覆運算器,以反覆查看集合中的專案。

GetAt(UInt32)

傳回位於指定索引處的專案。

GetMany(UInt32, Transition[])

擷取單一傳遞反覆運算器中的多個元素。

GetView()

取得集合中的不可變檢視。

IndexOf(Transition, UInt32)

擷取指定專案的索引。

InsertAt(UInt32, Transition)

在指定的索引處插入指定的專案。

RemoveAt(UInt32)

移除指定之索引處的項目。

RemoveAtEnd()

拿掉集合中的最後一個專案。

ReplaceAll(Transition[])

一開始清除集合,然後將提供的數位插入為新專案。

SetAt(UInt32, Transition)

將位於指定索引的值設定為指定的 轉換 值。

適用於

另請參閱