wp7 --缓动动画
 <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <!--TitlePanel 包含应用程序的名称和页标题-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="页面名称" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>
 <!--ContentPanel - 在此处放置其他内容-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Click="Button_Click" Width="200" Height="100" Margin="6,6,250,501" />
            <Canvas  x:Name="Layout"></Canvas>
        </Grid>
    </Grid>
 private void Button_Click(object sender, RoutedEventArgs e)
        {
            MoveStoryBoard();
        }
        Rectangle myRectangle;
        private void MoveStoryBoard()
        {
            myRectangle = new Rectangle();
            Layout.Resources.Remove("unique_id");
            // of the animation.
            
            myRectangle.Width = 200;
            myRectangle.Height = 200;
            Color myColor = Color.FromArgb(255, 255, 0, 0);
            SolidColorBrush myBrush = new SolidColorBrush();
            myBrush.Color = myColor;
            myRectangle.Fill = myBrush;
            // Add the rectangle to the tree.
            Layout.Children.Add(myRectangle);
            // Create a duration of 2 seconds.
            Duration duration = new Duration(TimeSpan.FromSeconds(2));
            // Create two DoubleAnimations and set their properties.
            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();
            myDoubleAnimation1.Duration = duration;
            myDoubleAnimation2.Duration = duration;
            Storyboard sb = new Storyboard();
            sb.Duration = duration;
            sb.Children.Add(myDoubleAnimation1);
            sb.Children.Add(myDoubleAnimation2);
            Storyboard.SetTarget(myDoubleAnimation1, myRectangle);
            Storyboard.SetTarget(myDoubleAnimation2, myRectangle);
            // Set the attached properties of Canvas.Left and Canvas.Top
            // to be the target properties of the two respective DoubleAnimations.
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
            Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));
            myDoubleAnimation1.To = 200;
            myDoubleAnimation2.To = 200;
            QuarticEase ease = new QuarticEase();
            ease.EasingMode = EasingMode.EaseOut;
            myDoubleAnimation1.EasingFunction = ease;
            QuarticEase ease2 = new QuarticEase();
            ease2.EasingMode = EasingMode.EaseOut;
            myDoubleAnimation2.EasingFunction = ease2;
            // Make the Storyboard a resource.
            Layout.Resources.Add("unique_id", sb);
            // Begin the animation.
            sb.Begin();
            sb.Completed += new EventHandler(sb_Completed);
        }
        void sb_Completed(object sender, EventArgs e)
        {
            Layout.Children.Remove(myRectangle);
        }

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号