' Set the animation to target the IsEnabled property ' Value becomes true after the fourth second.ī(New DiscreteBooleanKeyFrame(True, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(4.0)))) ' KeyTime - Target value (KeyValue) ' Value becomes false after 3 and half seconds.ī(New DiscreteBooleanKeyFrame(False, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.5)))) ' KeyTime - Target value (KeyValue) ' Value becomes true after the third second.ī(New DiscreteBooleanKeyFrame(True, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.0)))) ' KeyTime - Target value (KeyValue) ' Value becomes false after the 2nd second.ī(New DiscreteBooleanKeyFrame(False, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.0)))) ' KeyTime - Target value (KeyValue) ' Value becomes true after the first second.ī(New DiscreteBooleanKeyFrame(True, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.0)))) ' KeyTime - Target value (KeyValue) Only discrete key frames can be usedī(New DiscreteBooleanKeyFrame(False, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.0)))) ' KeyTime - Target value (KeyValue) ' Discrete key frames create sudden "jumps" between values ' All the key frames defined below are DiscreteBooleanKeyFrames. ' animate the IsEnabled property of the Button.ĭim booleanAnimation As New BooleanAnimationUsingKeyFrames()īooleanAnimation.Duration = TimeSpan.FromSeconds(4) ' Create a BooleanAnimationUsingKeyFrames to Me.RegisterName("AnimatedButton", myButton) ' Create the Button that is the target of the animation. MyTextBlock.Text = "Click the button to animate its IsEnabled property" & " with aBooleanAnimationUsingKeyFrames animation." ' Create a TextBlock to introduce the example. MyStackPanel.Orientation = Orientation.Vertical NameScope.SetNameScope(Me, New NameScope()) ' Create a NameScope for this page so that Title = "BooleanAnimationUsingKeyFrames Example" Public Class BooleanAnimationUsingKeyFramesExample ' animate the IsEnabled property of a button. ' Demonstrates a BooleanAnimationUsingKeyFrames. MyButton.Click += delegate(object sender, RoutedEventArgs e) Start the storyboard when the button is clicked. Storyboard myStoryboard = new Storyboard() Create a storyboard to apply the animation. Storyboard.SetTargetName(booleanAnimation, "AnimatedButton") īooleanAnimation, new PropertyPath(Button.IsEnabledProperty)) Set the animation to target the IsEnabled property KeyTime.FromTimeSpan(TimeSpan.FromSeconds(4.0))) // KeyTime Value becomes true after the fourth second. KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.5))) // KeyTime Value becomes false after 3 and half seconds. KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.0))) // KeyTime Value becomes true after the third second. KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.0))) // KeyTime Value becomes false after the 2nd second. KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.0))) // KeyTime Value becomes true after the first second. KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.0))) // KeyTime Discrete key frames create sudden "jumps" between values All the key frames defined below are DiscreteBooleanKeyFrames. animate the IsEnabled property of the Button.īooleanAnimationUsingKeyFrames booleanAnimationīooleanAnimation.Duration = TimeSpan.FromSeconds(4) Create a BooleanAnimationUsingKeyFrames to Create the Button that is the target of the animation. + " with aBooleanAnimationUsingKeyFrames animation." MyTextBlock.Text = "Click the button to animate its IsEnabled property" Create a TextBlock to introduce the example. StackPanel myStackPanel = new StackPanel() NameScope.SetNameScope(this, new NameScope()) Create a NameScope for this page so that Public BooleanAnimationUsingKeyFramesExample() Public class BooleanAnimationUsingKeyFramesExample : Page animate the IsEnabled property of a button. Demonstrates a BooleanAnimationUsingKeyFrames. Fotogrammi chiave discreti come DiscreteBooleanKeyFrame la creazione di salti improvvisi tra valori, ovvero il movimento dell'animazione è a cretino. Tutti i fotogrammi chiave in questo esempio usano un'istanza della DiscreteBooleanKeyFrame classe. Nell'esempio seguente viene utilizzata la BooleanAnimationUsingKeyFrames classe per animare la IsEnabled proprietà di un Button controllo. In questo esempio viene illustrato come animare il valore della proprietà booleana di un Button controllo usando fotogrammi chiave. Commenti e suggerimenti In questo articolo
0 Comments
Leave a Reply. |