簡體   English   中英

嘗試簡單的角色動畫時,WPF會拋出異常

[英]WPF throws an exception when trying out a simple character animation

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,加載窗口時,我想動畫“拍手”。 謝謝

我認為問題是你正在嘗試綁定到TextBlock.Content。 但是TextBlock具有“Text”屬性,它不是ContentControl。 因此,如果您將其更改為“文本”,您應該沒問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM