尝试简单的角色动画时,WPF会抛出异常

时间:2012-03-23 15:57:18

标签: c# wpf

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '54' and line position '22'.

尝试运行以下XAML文件时遇到错误

         <Border Background="AliceBlue"  CornerRadius="33" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    VerticalAlignment="top" HorizontalAlignment="Center" BorderThickness="0"  BorderBrush="#ccc" Padding="10" SnapsToDevicePixels="True" Width="298" Margin="113,12,117,0">
        <TextBlock FontFamily="Comic Sans MS"  
                   FontSize="25" 
                   TextWrapping="Wrap" 
                   x:Name="txtBlkThanks" 
                   Foreground="Gray"                        
                   Width="198" Height="39"
                   >
            Clap your hands
            <TextBlock.Triggers>
                <EventTrigger RoutedEvent="TextBlock.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <StringAnimationUsingKeyFrames Storyboard.TargetName="txtBlkThanks"
                                                           Storyboard.TargetProperty="(TextBlock.Content)"
                                                           Duration="0:0:8"
                                                           FillBehavior="HoldEnd">
                                <DiscreteStringKeyFrame Value="" KeyTime="0:0:0"/>
                                <DiscreteStringKeyFrame Value="C" KeyTime="0:0:1"/>                                                                        
                                <DiscreteStringKeyFrame Value="Cl" KeyTime="0:0:1.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Cla" KeyTime="0:0:2"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap" KeyTime="0:0:2.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap y" KeyTime="0:0:3"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap yo" KeyTime="0:0:3.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap you" KeyTime="0:0:4"/>
                                <DiscreteStringKeyFrame Value="Clap your" KeyTime="0:0:4.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap your h" KeyTime="0:0:5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap your ha" KeyTime="0:0:5.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap your han" KeyTime="0:0:6"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap your hand" KeyTime="0:0:6.5"/>                                                                        
                                <DiscreteStringKeyFrame Value="Clap your hands" KeyTime="0:0:7"/>                                                                      
                            </StringAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </TextBlock.Triggers>
        </TextBlock>
     </Border>

我想在加载textBlock,加载窗口时动画“拍手”。 谢谢

1 个答案:

答案 0 :(得分:2)

我认为问题在于您正在尝试绑定到TextBlock.Content。但是TextBlock具有“Text”属性,它不是ContentControl。因此,如果您将其更改为“文本”,那么您应该没问题。