ColorAnimationUsingKeyFrames Classe

Définition

Anime la valeur d’une propriété Color le long d’un ensemble d’images clés.

public ref class ColorAnimationUsingKeyFrames 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 ColorAnimationUsingKeyFrames 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 ColorAnimationUsingKeyFrames 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 ColorAnimationUsingKeyFrames : 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 ColorAnimationUsingKeyFrames : Timeline
Public NotInheritable Class ColorAnimationUsingKeyFrames
Inherits Timeline
<ColorAnimationUsingKeyFrames ...>
  oneOrMoreColorKeyFrames
</ColorAnimationUsingKeyFrames>
Héritage
Object Platform::Object IInspectable DependencyObject Timeline ColorAnimationUsingKeyFrames
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 ColorAnimationUsingKeyFrames pour animer la propriété Background d’un StackPanel. Cette animation utilise trois images clés de la manière suivante :

  1. Pendant les deux premières secondes, LinearColorKeyFrame change progressivement la couleur du vert au rouge. Les images clés linéaires comme LinearColorKeyFrame créent une transition linéaire fluide entre les valeurs.
  2. À la fin de la demi-seconde suivante, DiscreteColorKeyFrame change rapidement la couleur du rouge au jaune. Les images clés discrètes comme DiscreteColorKeyFrame créent des changements soudains entre les valeurs ; l’animation se produit rapidement et n’a aucune interpolation entre les valeurs.
  3. Au cours des deux dernières secondes, SplineColorKeyFrame change à nouveau la couleur, cette fois du jaune au vert. Les images clés spline comme SplineColorKeyFrame créent une transition de variable entre les valeurs en fonction des valeurs de la propriété KeySpline . Une keySpline permet de modifier la relation temps/valeur pendant la durée de l’animation pour qu’elle soit non linéaire, et en particulier la relation peut être une courbe qui serait difficile à produire avec des images clés individuelles. Dans cet exemple, le changement de couleur commence lentement, puis accélère de façon exponentielle jusqu’à la fin du segment temporel.
<StackPanel x:Name="myStackPanel" Background="Red"
Loaded="Start_Animation">
    <StackPanel.Resources>
        <Storyboard x:Name="colorStoryboard">

            <ColorAnimationUsingKeyFrames Storyboard.TargetName="myStackPanel" 
      Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                
                <!-- Go from green to red in the first 2 seconds. LinearColorKeyFrame creates
                a smooth, linear animation between values. -->
                <LinearColorKeyFrame Value="Blue" KeyTime="00:00:02" />

                <!-- In the next half second, go to yellow. DiscreteColorKeyFrame creates a 
                sudden jump between values. -->
                <DiscreteColorKeyFrame Value="Yellow" KeyTime="00:00:2.5" />

                <!-- In the final 2 seconds of the animation, go from yellow back to green. SplineColorKeyFrame 
                creates a variable transition between values depending on the KeySpline property. In this example,
                the animation starts off slow but toward the end of the time segment, it speeds up exponentially.-->
                <SplineColorKeyFrame Value="Green" KeyTime="00:00:4.5" KeySpline="0.6,0.0 0.9,0.00" />

            </ColorAnimationUsingKeyFrames>
        </Storyboard>
    </StackPanel.Resources>
</StackPanel>
// Start the animation when the object loads
private void Start_Animation(object sender, RoutedEventArgs e)
{
    colorStoryboard.Begin();
}
' Start the animation when the object loads
Private Sub Start_Animation(ByVal sender As Object, ByVal e As EventArgs)
    colorStoryboard.Begin()
End Sub

Constructeurs

ColorAnimationUsingKeyFrames()

Initialise une nouvelle instance de la classe ColorAnimationUsingKeyFrames.

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 installation 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 ColorKeyFrame 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 le taux, par rapport à son parent, auquel le moment 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’applique 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 objet 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 l’objet Storyboard a terminé la lecture.

(Hérité de Timeline)

S’applique à

Voir aussi