我正在使用两个故事板制作动画。它首先播放正常,但第二次播放时第一个故事板根本不显示。这是我的代码示例。
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Width="1920" Height="1080"
xmlns:my="clr-namespace:vMixTitleLibrary;assembly=vMixTitleLibrary">
<UserControl.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="Image2">
<SplineDoubleKeyFrame KeyTime="0" Value="-476"/>
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="Image1">
<SplineDoubleKeyFrame KeyTime="0" Value="236"/>
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="Programme">
<SplineDoubleKeyFrame KeyTime="0" Value="236"/>
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard2">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="Image1">
<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="-1312"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="Programme">
<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="-1312"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="Image2">
<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="-968"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</UserControl.Triggers>
<Grid>
<Image Source="UpNextBar.png" Name="Image1" Width="1199" Height="100" Margin="48,871,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" >
<Image.RenderTransform>
<TranslateTransform/>
</Image.RenderTransform>
</Image>
<Image Source="UpNextText.png" Name="Image2" Width="368" Height="177" Margin="41,735,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" >
<Image.RenderTransform>
<TranslateTransform/>
</Image.RenderTransform>
</Image>
<my:TextBlockDesign Fill="#FF000000" FontSize="64" Text="Programme Title" Name="Programme" Width="984" Height="74" Margin="223,885,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" >
<my:TextBlockDesign.RenderTransform>
<TranslateTransform/>
</my:TextBlockDesign.RenderTransform>
</my:TextBlockDesign>
</Grid>
</UserControl>
动画在第一次叠加时播放,但是storyboard1第二次不出现。删除叠加层时,它会出现在故事板1应该结束的位置,并继续播放storyboard2动画。
请知道问题可能是什么?
答案 0 :(得分:0)
尝试在故事情节中设置第一个关键帧作为默认标题并设置属性HIDDEN,然后将动画设置为usuall。 因此,在播放storyline2并再次播放storuline1之后,所有对象都设置为默认位置并将被隐藏,然后再次正常播放