ObjectAnimationUsingKeyFrames Kelas

Definisi

Menganimasikan nilai properti Objek di sepanjang sekumpulan KeyFrames selama Durasi tertentu.

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>
Warisan
Object Platform::Object IInspectable DependencyObject Timeline ObjectAnimationUsingKeyFrames
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Contoh

Contoh berikut menggunakan kelas ObjectAnimationUsingKeyFrames untuk menganimasikan properti IsianPersegi Panjang. Animasi ini menggunakan dua bingkai kunci dengan cara berikut:

  1. Menggunakan DiscreteObjectKeyFrame, properti IsianPersegi Panjang tiba-tiba berubah menjadi LinearGradientBrush setelah dua detik pertama animasi.
  2. Setelah detik ketiga animasi, properti Isian tiba-tiba diubah ke LinearGradientBrush yang berbeda, yang tetap hingga akhir animasi (total empat detik).
<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

Konstruktor

ObjectAnimationUsingKeyFrames()

Menginisialisasi instans baru kelas ObjectAnimationUsingKeyFrames .

Properti

AutoReverse

Mendapatkan atau menetapkan nilai yang menunjukkan apakah garis waktu diputar secara terbalik setelah menyelesaikan perulangan ke depan.

(Diperoleh dari Timeline)
BeginTime

Mendapatkan atau mengatur waktu di mana Garis Waktu ini harus dimulai.

(Diperoleh dari Timeline)
Dispatcher

Mendapatkan CoreDispatcher yang dikaitkan dengan objek ini. CoreDispatcher mewakili fasilitas yang dapat mengakses DependencyObject pada utas UI meskipun kode dimulai oleh utas non-UI.

(Diperoleh dari DependencyObject)
Duration

Mendapatkan atau mengatur lamanya waktu diputarnya garis waktu ini, tidak menghitung pengulangan.

(Diperoleh dari Timeline)
EnableDependentAnimation

Mendapatkan atau menetapkan nilai yang menyatakan apakah properti animasi yang dianggap sebagai animasi dependen harus diizinkan untuk menggunakan deklarasi animasi ini.

EnableDependentAnimationProperty

Mengidentifikasi properti dependensi EnableDependentAnimation .

FillBehavior

Mendapatkan atau menetapkan nilai yang menentukan bagaimana animasi berperilaku setelah mencapai akhir periode aktifnya.

(Diperoleh dari Timeline)
KeyFrames

Mendapatkan koleksi objek ObjectKeyFrame yang menentukan animasi.

RepeatBehavior

Mendapatkan atau mengatur perilaku berulang dari garis waktu ini.

(Diperoleh dari Timeline)
SpeedRatio

Mendapatkan atau menetapkan tarif, relatif terhadap induknya, pada saat itu berlangsung untuk Garis Waktu ini.

(Diperoleh dari Timeline)

Metode

ClearValue(DependencyProperty)

Menghapus nilai lokal properti dependensi.

(Diperoleh dari DependencyObject)
GetAnimationBaseValue(DependencyProperty)

Mengembalikan nilai dasar apa pun yang ditetapkan untuk properti dependensi, yang akan berlaku dalam kasus di mana animasi tidak aktif.

(Diperoleh dari DependencyObject)
GetValue(DependencyProperty)

Mengembalikan nilai efektif properti dependensi saat ini dari DependencyObject.

(Diperoleh dari DependencyObject)
ReadLocalValue(DependencyProperty)

Mengembalikan nilai lokal properti dependensi, jika nilai lokal ditetapkan.

(Diperoleh dari DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Mendaftarkan fungsi pemberitahuan untuk mendengarkan perubahan pada DependencyProperty tertentu pada instans DependencyObject ini.

(Diperoleh dari DependencyObject)
SetValue(DependencyProperty, Object)

Mengatur nilai lokal properti dependensi pada DependencyObject.

(Diperoleh dari DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Membatalkan pemberitahuan perubahan yang sebelumnya terdaftar dengan memanggil RegisterPropertyChangedCallback.

(Diperoleh dari DependencyObject)

Acara

Completed

Terjadi ketika objek Storyboard telah selesai diputar.

(Diperoleh dari Timeline)

Berlaku untuk

Lihat juga