2010-10-30 9 views
2

J'ai une partie de ma page dédiée à l'affichage des crédits et il y a trois blocs de texte qui défilent verticalement. J'ai cependant besoin de chaque ligne pour faire une pause quand elle se met en position (une position dans le panneau) et ensuite continuer après une seconde ou deux. Sans rendre tout cela très complexe, je ne sais pas comment faire cela. J'avais les trois lignes qui défilaient ensemble mais je ne savais pas comment faire une pause.WPF - Comment faire défiler le texte verticalement ET Pause

J'ai même essayé DoubleAnimationUsingKeyFrames mais je n'ai pas réussi à l'obtenir non plus.

Des pointeurs?

Répondre

3

L'astuce consiste à définir BeginTime des animations, comme dans cet exemple.

<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Titles" SizeToContent="WidthAndHeight"> 
    <Window.Resources> 
     <Style TargetType="Grid"> 
      <Setter Property="Width" Value="300" /> 
      <Setter Property="Height" Value="100" /> 
     </Style> 
     <Style TargetType="TextBlock"> 
      <Setter Property="HorizontalAlignment" Value="Center" /> 
      <Setter Property="VerticalAlignment" Value="Center" /> 
      <Setter Property="FontSize" Value="20" /> 
     </Style> 
     <Style TargetType="StackPanel"> 
      <Setter Property="Canvas.Top" Value="200" /> 
      <Style.Triggers> 
       <EventTrigger RoutedEvent="Loaded"> 
        <BeginStoryboard> 
         <Storyboard RepeatBehavior="Forever"> 
          <DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)" From="300" To="100" BeginTime="0:00:00" Duration="0:00:02" /> 
          <DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)" From="100" To="0" BeginTime="0:00:04" Duration="0:00:01" /> 
          <DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)" From="0" To="-100" BeginTime="0:00:06" Duration="0:00:01" /> 
          <DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)" From="-100" To="-300" BeginTime="0:00:08" Duration="0:00:02" /> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
      </Style.Triggers> 
     </Style> 
    </Window.Resources> 
    <Canvas Width="300" Height="300"> 
     <StackPanel> 
      <Grid> 
       <TextBlock Text="Name 1" /> 
      </Grid> 
      <Grid> 
       <TextBlock Text="Name 2" /> 
      </Grid> 
      <Grid> 
       <TextBlock Text="Name 3" /> 
      </Grid> 
     </StackPanel> 
    </Canvas> 
</Window> 
+0

wow - Je ne connais jamais le début. Merci!!! – Jeff

Questions connexes