• 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);
    }

  • 相关阅读:
    PHP date函数时间相差8个小时解决办法
    PHP中include()与require()的区别说明
    post与get区别
    MFC 对话框控件自动布局
    Apache php Mysql部署(一)下载安装
    apache 重定向
    clistctrl失去焦点高亮显示选中行
    格式化字符串
    unicode编码与utf-8 区别
    string的实现
  • 原文地址:https://www.cnblogs.com/androllen/p/3108401.html
Copyright © 2020-2023  润新知