ObjectAnimationUsingKeyFrames Classe

Définition

Anime la valeur d’une propriété Object le long d’un ensemble d’images clés sur une durée spécifiée.

public ref class ObjectAnimationUsingKeyFrames sealed : Timeline
/// [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)]
/// [Windows.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
class ObjectAnimationUsingKeyFrames final : Timeline
/// [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.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class ObjectAnimationUsingKeyFrames final : Timeline
[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)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
public sealed class ObjectAnimationUsingKeyFrames : Timeline
[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.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class ObjectAnimationUsingKeyFrames : Timeline
Public NotInheritable Class ObjectAnimationUsingKeyFrames
Inherits Timeline
<ObjectAnimationUsingKeyFrames>oneOrMoreDiscreteObjectKeyFrames</ObjectAnimationUsingKeyFrames>
Héritage
Object Platform::Object IInspectable DependencyObject Timeline ObjectAnimationUsingKeyFrames
Attributs

Configuration requise pour Windows

Famille d’appareils
Windows 10 (introduit dans 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v1.0)

Exemples

L’exemple suivant utilise la classe ObjectAnimationUsingKeyFrames pour animer la propriété Fill d’un rectangle. Cette animation utilise deux images clés de la manière suivante :

  1. À l’aide d’un DiscreteObjectKeyFrame, la propriété Fill du Rectangle devient soudainement LinearGradientBrush après les deux premières secondes de l’animation.
  2. Après la troisième seconde de l’animation, la propriété Fill est soudainement remplacée par un autre LinearGradientBrush, qui reste jusqu’à la fin de l’animation (quatre secondes au total).
<StackPanel>
    <StackPanel.Resources>
        <Storyboard x:Name="myStoryboard">

            <!-- ObjectAnimationUsingKeyFrames is used to animate properties that take
         an object as a value. This animation lasts for 4 seconds using 3 KeyFrames which
         swap different brush objects at regular intervals, making the background of the Page
         change. -->
            <ObjectAnimationUsingKeyFrames
         Storyboard.TargetName="animatedRectangle"
         Storyboard.TargetProperty="Fill"
         Duration="0:0:4" RepeatBehavior="Forever">
                <ObjectAnimationUsingKeyFrames.KeyFrames>

                    <!-- Note: Only discrete interpolation (DiscreteObjectKeyFrame) is available for 
                use with ObjectAnimationUsingKeyFrames which merely swaps objects according to
                a specified timeline. Other types of interpolation are too problematic to apply
                to objects.  -->
                    <!-- Using a DiscreteObjectKeyFrame, the Fill property of the Rectangle suddenly  
                changes to a LinearGradientBrush after the first two seconds of the animation. -->
                    <DiscreteObjectKeyFrame KeyTime="0:0:2">
                        <DiscreteObjectKeyFrame.Value>
                            <LinearGradientBrush>
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="Yellow" Offset="0.0" />
                                    <GradientStop Color="Orange" Offset="0.5" />
                                    <GradientStop Color="Red" Offset="1.0" />
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>

                    <!-- After the third second of the animation, the Fill property is suddenly changed 
                to a different LinearGradientBrush which remains until the end of the animation 
                (4 seconds total). -->
                    <DiscreteObjectKeyFrame KeyTime="0:0:3">
                        <DiscreteObjectKeyFrame.Value>
                            <LinearGradientBrush>
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="White" Offset="0.0" />
                                    <GradientStop Color="MediumBlue" Offset="0.5" />
                                    <GradientStop Color="Black" Offset="1.0" />
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>

                </ObjectAnimationUsingKeyFrames.KeyFrames>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </StackPanel.Resources>

    <!-- The Fill property of this rectangle is animated. -->
    <Rectangle x:Name="animatedRectangle" Loaded="Rectangle_Loaded" Width="300" Height="300" />

</StackPanel>
// When the rectangle loads, begin the animation.
private void Rectangle_Loaded(object sender, RoutedEventArgs e)
{
    myStoryboard.Begin();
}
' When the rectangle loads, begin the animation.
Private Sub Rectangle_Loaded(ByVal sender As Object, ByVal e As EventArgs)
    myStoryboard.Begin()
End Sub

Constructeurs

ObjectAnimationUsingKeyFrames()

Initialise une nouvelle instance de la classe ObjectAnimationUsingKeyFrames.

Propriétés

AutoReverse

Obtient ou définit une valeur qui indique si la chronologie est lue en sens inverse après avoir effectué une itération vers l’avant.

(Hérité de Timeline)
BeginTime

Obtient ou définit l’heure à laquelle cette chronologie doit commencer.

(Hérité de Timeline)
Dispatcher

Obtient le CoreDispatcher auquel cet objet est associé. CoreDispatcher représente une fonctionnalité qui peut accéder à DependencyObject sur le thread d’interface utilisateur, même si le code est initié par un thread autre que l’interface utilisateur.

(Hérité de DependencyObject)
Duration

Obtient ou définit la durée de cette chronologie, sans prendre en compte les répétitions.

(Hérité de Timeline)
EnableDependentAnimation

Obtient ou définit une valeur qui déclare si les propriétés animées considérées comme des animations dépendantes doivent être autorisées à utiliser cette déclaration d’animation.

EnableDependentAnimationProperty

Identifie la propriété de dépendance EnableDependentAnimation .

FillBehavior

Obtient ou définit une valeur qui spécifie le comportement de l’animation une fois qu’elle a atteint la fin de sa période active.

(Hérité de Timeline)
KeyFrames

Obtient la collection d’objets ObjectKeyFrame qui définissent l’animation.

RepeatBehavior

Obtient ou définit le comportement à répétition de cette chronologie.

(Hérité de Timeline)
SpeedRatio

Obtient ou définit la vitesse, par rapport à son parent, à laquelle progresse pour cette chronologie.

(Hérité de Timeline)

Méthodes

ClearValue(DependencyProperty)

Efface la valeur locale d’une propriété de dépendance.

(Hérité de DependencyObject)
GetAnimationBaseValue(DependencyProperty)

Retourne toute valeur de base établie pour une propriété de dépendance, qui s’appliquerait dans les cas où une animation n’est pas active.

(Hérité de DependencyObject)
GetValue(DependencyProperty)

Retourne la valeur effective actuelle d’une propriété de dépendance à partir d’un DependencyObject.

(Hérité de DependencyObject)
ReadLocalValue(DependencyProperty)

Retourne la valeur locale d’une propriété de dépendance, si une valeur locale est définie.

(Hérité de DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Inscrit une fonction de notification pour écouter les modifications apportées à un DependencyProperty spécifique sur ce instance DependencyObject.

(Hérité de DependencyObject)
SetValue(DependencyProperty, Object)

Définit la valeur locale d’une propriété de dépendance sur un DependencyObject.

(Hérité de DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Annule une notification de modification précédemment inscrite en appelant RegisterPropertyChangedCallback.

(Hérité de DependencyObject)

Événements

Completed

Se produit lorsque la lecture de l’objet Storyboard est terminée.

(Hérité de Timeline)

S’applique à

Voir aussi