2013-11-15 31 views
0

在我的項目中,我希望選取n張圖片。我嘗試過但沒有成功。當我給持續時間在相同的時候,所有的圖像被組合並移動。圖片在wpf中的marque動畫?

我的XAML -

<Grid> 
     <Canvas x:Name="MyCanvas" VerticalAlignment="Center"> 
      <Canvas.Triggers> 
       <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
        <BeginStoryboard > 
         <Storyboard Storyboard.TargetName="img1" Storyboard.TargetProperty="(Canvas.Left)"> 
          <DoubleAnimation From="0" To="514" Duration="0:0:20" /> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
       <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
        <BeginStoryboard > 
         <Storyboard Storyboard.TargetName="img2" Storyboard.TargetProperty="(Canvas.Left)"> 
          <DoubleAnimation From="0" To="514" Duration="0:0:20" /> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
       <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
        <BeginStoryboard > 
         <Storyboard Storyboard.TargetName="img3" Storyboard.TargetProperty="(Canvas.Left)"> 
          <DoubleAnimation From="0" To="514" Duration="0:0:20" /> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
      </Canvas.Triggers> 
      <Image Name="img1" Source="/Images/01.jpg" Height="180" Width="120" /> 
      <Image Name="img2" Source="/Images/02.jpg" Height="180" Width="120" /> 
      <Image Name="img3" Source="/Images/03.jpg" Height="180" Width="120" /> 
     </Canvas> 
    </Grid> 

我的模型是 -

enter image description here

回答

1

請參考以下鏈接,並在您的案件,不適用它。

http://weblogs.asp.net/razan/archive/2009/10/01/creating-marquee-scrolling-text-in-wpf.aspx

更新1:

修改你的代碼如下似乎滿足您的要求

<Grid> 
      <Canvas x:Name="MyCanvas" VerticalAlignment="Center"> 
       <Canvas.Triggers> 
        <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
         <BeginStoryboard > 
          <Storyboard Storyboard.TargetName="panel" Storyboard.TargetProperty="(Canvas.Left)"> 
           <DoubleAnimation From="0" To="514" Duration="0:0:20" /> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger>     
       </Canvas.Triggers> 
       <StackPanel x:Name="panel" Orientation="Horizontal"> 
        <Image Name="img1" Source="/Images/01.jpg" Height="180" Width="120" /> 
        <Image Name="img2" Source="/Images/02.jpg" Height="180" Width="120" /> 
        <Image Name="img3" Source="/Images/03.jpg" Height="180" Width="120" /> 
       </StackPanel> 
      </Canvas> 
     </Grid> 
+0

您的鏈接給選取框的解決方案。但是我有n張圖片,我如何像火車一樣連續移動。 – Sagotharan

+1

@Sagotharan我做了一個有趣的更新..:P –

+0

圖像字幕不繼續。我在image1之前wana image3,同時壓縮。它不會發生。請參閱step2和step3 – Sagotharan