WPF XAML动画(新手)

rag*_*ius 3 wpf animation xaml

我正在尝试在XAML中测试动画.我的意图是制作一个字体大小的脉冲(永远增加和减少).但是当我输入下面的代码时,Visual Studio无法识别该类DoubleAnimation.我究竟做错了什么?

<Window x:Class="testingAnimation.MainWindow"
        xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        Title="MainWindow" Height="350" Width="525">
 <StackPanel>
    <TextBlock Text="HELLO">
       <TextBlock.FontSize>
            <DoubleAnimation />
       </TextBlock.FontSize>
    </TextBlock>
 </StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

Fed*_*gui 6

您需要Storyboard在加载时声明并启动它:

 <TextBlock x:Name="Text" Text="Hello!!">
            <TextBlock.Triggers>
                <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard Duration="00:00:01" RepeatBehavior="Forever" AutoReverse="True">
                                <DoubleAnimation From="10" To="20" Storyboard.TargetName="Text" Storyboard.TargetProperty="FontSize"/>   
                            </Storyboard>                            
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </TextBlock.Triggers>
    </TextBlock>
Run Code Online (Sandbox Code Playgroud)