<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="" Height="300" Width="300">
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<ParallelTimeline>
<DoubleAnimation x:Name="Animation1" Storyboard.TargetProperty="Width" From="140" To="50"
AutoReverse="True" RepeatBehavior="Forever" />
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" AutoReverse="True" RepeatBehavior="Forever" />
</ParallelTimeline>
</Storyboard>
</Window.Resources>
<UniformGrid>
<Button x:Name="button3" Content="Method 3" Click="Button3_Click" Loaded="Button3_Loaded" />
</UniformGrid>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media.Animation
Namespace WpfApplication1
Public Partial Class Window1
Inherits Window
Private opacityClock As AnimationClock
Private widthClock As AnimationClock
Public Sub New()
InitializeComponent()
End Sub
Private Sub Button3_Loaded(sender As Object, e As RoutedEventArgs)
Dim opacityAnimation As New DoubleAnimation(1.0, 0.5, TimeSpan.FromSeconds(1), FillBehavior.HoldEnd)
opacityAnimation.RepeatBehavior = RepeatBehavior.Forever
opacityAnimation.AutoReverse = True
opacityClock = opacityAnimation.CreateClock()
button3.ApplyAnimationClock(Button.OpacityProperty, opacityClock)
Dim widthAnimation As New DoubleAnimation(140.0, 50.0, TimeSpan.FromSeconds(1), FillBehavior.HoldEnd)
widthAnimation.RepeatBehavior = RepeatBehavior.Forever
widthAnimation.AutoReverse = True
widthClock = widthAnimation.CreateClock()
button3.ApplyAnimationClock(Button.WidthProperty, widthClock)
End Sub
Private Sub Button3_Click(sender As Object, e As RoutedEventArgs)
opacityClock.Controller.Remove()
widthClock.Controller.Remove()
End Sub
End Class
End Namespace
|