ObjectAnimationUsingKeyFrames Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
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
/// [Microsoft.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
/// [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 ObjectAnimationUsingKeyFrames final : Timeline
[Microsoft.UI.Xaml.Markup.ContentProperty(Name="KeyFrames")]
[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 ObjectAnimationUsingKeyFrames : Timeline
Public NotInheritable Class ObjectAnimationUsingKeyFrames
Inherits Timeline
<ObjectAnimationUsingKeyFrames>oneOrMoreDiscreteObjectKeyFrames</ObjectAnimationUsingKeyFrames>
- Héritage
- Attributs
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 :
- À l’aide d’un DiscreteObjectKeyFrame, la propriété Fill du Rectangle passe soudainement à un LinearGradientBrush après les deux premières secondes de l’animation.
- 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();
}
Constructeurs
| Nom | Description |
|---|---|
| ObjectAnimationUsingKeyFrames() |
Initialise une nouvelle instance de la classe ObjectAnimationUsingKeyFrames . |
Propriétés
| Nom | Description |
|---|---|
| AutoReverse |
Obtient ou définit une valeur qui indique si la chronologie est lue à l’inverse une fois qu’elle a terminé 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 |
Retourne |
| DispatcherQueue |
Obtient le |
| Duration |
Obtient ou définit la durée pendant laquelle cette chronologie joue, sans compter 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 après qu’elle 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étitif de cette chronologie. (Hérité de Timeline) |
| SpeedRatio |
Obtient ou définit le taux, par rapport à son parent, au moment où il progresse pour cette chronologie. (Hérité de Timeline) |
Méthodes
| Nom | Description |
|---|---|
| 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 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 à une dependencyProperty spécifique sur cette 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 qui a été précédemment inscrite en appelant RegisterPropertyChangedCallback. (Hérité de DependencyObject) |
Événements
| Nom | Description |
|---|---|
| Completed |
Se produit lorsque l’objet Storyboard a terminé la lecture. (Hérité de Timeline) |