Silverlight滑動動畫

來源:互聯網
上載者:User

話說對於剛剛學習SL的人來說,特別是從HTML跳過來 玩動畫的時候 那邊的思路很多不通的,在SL裡面的滑動直接更換Margin不行,後面慢慢摸索才弄出來 的 希望對大家有協助

 

目前只是寫了一步,以後可以根據自己擴充

Dome

http://download.csdn.net/detail/qq873113580/5993237

前台

<Grid x:Name="LayoutRoot" Background="White">        <Grid Background="AliceBlue" HorizontalAlignment="Left" Height="100" Margin="206,47,0,0" VerticalAlignment="Top" Width="400">            <StackPanel x:Name="spImages" Orientation="Horizontal" VerticalAlignment="Stretch" Width="900">                <StackPanel.RenderTransform>                    <TransformGroup>                        <TranslateTransform X="0"></TranslateTransform>                    </TransformGroup>                </StackPanel.RenderTransform>                <Image Width="100" Height="100" Source="Image/1.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/2.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/3.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/4.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/5.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/6.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/7.jpg" Stretch="Fill"/>                <Image Width="100" Height="100" Source="Image/8.jpg" Stretch="Fill"/>                <Button Content="Button" Width="75"/>            </StackPanel>        </Grid>        <Button Content="上一張" HorizontalAlignment="Left" Margin="531,181,0,0" VerticalAlignment="Top" Width="75"/>        <Button Content="下一張" HorizontalAlignment="Left" Margin="206,181,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>    </Grid>

 

後台

private void Button_Click_1(object sender, RoutedEventArgs e)        {            Storyboard storyBoard = new Storyboard();            //設定動畫軌跡            DoubleAnimation doubleAnimation = new DoubleAnimation();            //執行時間            doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500));            //變數大小            doubleAnimation.To = -100;            //綁定執行動畫的對象            Storyboard.SetTarget(doubleAnimation, this.spImages);            //設定執行動畫的屬性            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"));            //添加動畫            storyBoard.Children.Add(doubleAnimation);            //執行動畫            storyBoard.Begin();        }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.