问题
I am trying to use a text marquee like on this post Marquee Text
But i dont know how can i change the textblock content after a cycle of animation. thanks for your help.
I really stuck. please help me.
回答1:
Finally i found my answer
<TextBlock x:Name="_box" FontSize="64" Text="My Simple Text.">
<TextBlock.RenderTransform>
<TranslateTransform x:Name="AnimatedTranslateTransform" X="0" Y="0" />
</TextBlock.RenderTransform>
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard Name="MyStorybord">
<DoubleAnimation
Storyboard.TargetName="AnimatedTranslateTransform"
Storyboard.TargetProperty="X"
From="-300" To="300" Duration="0:0:5"
Completed="Timeline_OnCompleted" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
this cause the text box move one time. in method "Timeline_OnCompleted" I Change the Text And start the animation again.
private void Timeline_OnCompleted(object sender, EventArgs e)
{
_box.Text = MytextArray[index];
BeginStoryboard(MyStorybord);
}
thanks.
来源:https://stackoverflow.com/questions/30458484/marquee-text-witl-multi-content