如何同时执行多个动画 [英] How to execute multiple animation at same time

查看:48
本文介绍了如何同时执行多个动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何同时运行两个动画

I would like to know how I do to run two animations at the same time

 public async void OnClicked2Async(object sender, EventArgs e)
    {

        btn_login.SetValue(IsVisibleProperty, true);
        await btn_login.TranslateTo(0, 175, 1000); 
        await btn_novaconta.TranslateTo(0, -60, 1000); 
    }

这是我的代码

推荐答案

您可以通过将 Animation 实例添加到父/主 Animation 实例,然后将动画分组"提交它们:

You can "group" animations by adding Animation instances to a parent/master Animation instance and then committing them:

var button1Anim = new Animation(_ => button1.TranslateTo(0, 175, 1000));
var button2Anim = new Animation(_ => button2.TranslateTo(0, 175, 1000));
var masterAnimation = new Animation
{
    { 0, 1, button1Anim },
    { 0, 1, button2Anim }
};
masterAnimation.Commit(this, "MyAnim");

回复:自定义动画

这篇关于如何同时执行多个动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆