如何为 Silverlight Storyboard Begintime 执行代码隐藏而不是 xaml

发布于 2024-11-29 02:35:09 字数 702 浏览 1 评论 0原文

我需要将此 xaml 代码转换为开始时间的代码隐藏。

            <Storyboard BeginTime="0:0:10" x:Name="sbEllipse1">
                <DoubleAnimation
                         Storyboard.TargetName="myBrush1"
                         Storyboard.TargetProperty="RadiusX"
                         From="0" To="1"
                         Duration="0:0:20"
                         />
                <DoubleAnimation
                         Storyboard.TargetName="myBrush1"
                         Storyboard.TargetProperty="RadiusY"
                         From="0" To="1"
                         Duration="0:0:20"
                          />
            </Storyboard>

I need to translate this xaml code into code behind for begintime.

            <Storyboard BeginTime="0:0:10" x:Name="sbEllipse1">
                <DoubleAnimation
                         Storyboard.TargetName="myBrush1"
                         Storyboard.TargetProperty="RadiusX"
                         From="0" To="1"
                         Duration="0:0:20"
                         />
                <DoubleAnimation
                         Storyboard.TargetName="myBrush1"
                         Storyboard.TargetProperty="RadiusY"
                         From="0" To="1"
                         Duration="0:0:20"
                          />
            </Storyboard>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

惯饮孤独 2024-12-06 02:35:09
Storyboard sb = new Storyboard();
sb.BeginTime = TimeSpan.FromSeconds(10);
sb.Children.Add(new DoubleAnimation());
sb.Children.Add(new DoubleAnimation());
Storyboard sb = new Storyboard();
sb.BeginTime = TimeSpan.FromSeconds(10);
sb.Children.Add(new DoubleAnimation());
sb.Children.Add(new DoubleAnimation());
蓝眼睛不忧郁 2024-12-06 02:35:09
            Storyboard sb = new Storyboard();
            sb.BeginTime = TimeSpan.FromSeconds(10);

                    <DoubleAnimation
                     Storyboard.TargetName="myBrush1"
                     Storyboard.TargetProperty="RadiusX"
                     From="0" To="1"
                     Duration="0:0:20"
                     />
           //Equivalent code for the above is : 
            DoubleAnimation db = new DoubleAnimation();
            db.From = 0;
            db.To = 1;
            db.Duration = new Duration(TimeSpan.FromSeconds(20));
            Storyboard.SetTarget(db, myBrush1);
            Storyboard.SetTargetProperty(db, RadiusX);


                   <DoubleAnimation
                     Storyboard.TargetName="myBrush1"
                     Storyboard.TargetProperty="RadiusY"
                     From="0" To="1"
                     Duration="0:0:20"
                     />
           //Equivalent code for the above is :

            DoubleAnimation db1 = new DoubleAnimation();
            db1.From = 0;
            db1.To = 1;
            db1.Duration = new Duration(TimeSpan.FromSeconds(20));
            Storyboard.SetTarget(db, myBrush1);
            Storyboard.SetTargetProperty(db, RadiusY);
          //assigning both double animation to main Storyboard
            sb.Children.Add(db);
            sb.Children.Add(db1);
            myBrush1.Resources.Add(storyboard);
            sb.Begin();
            Storyboard sb = new Storyboard();
            sb.BeginTime = TimeSpan.FromSeconds(10);

                    <DoubleAnimation
                     Storyboard.TargetName="myBrush1"
                     Storyboard.TargetProperty="RadiusX"
                     From="0" To="1"
                     Duration="0:0:20"
                     />
           //Equivalent code for the above is : 
            DoubleAnimation db = new DoubleAnimation();
            db.From = 0;
            db.To = 1;
            db.Duration = new Duration(TimeSpan.FromSeconds(20));
            Storyboard.SetTarget(db, myBrush1);
            Storyboard.SetTargetProperty(db, RadiusX);


                   <DoubleAnimation
                     Storyboard.TargetName="myBrush1"
                     Storyboard.TargetProperty="RadiusY"
                     From="0" To="1"
                     Duration="0:0:20"
                     />
           //Equivalent code for the above is :

            DoubleAnimation db1 = new DoubleAnimation();
            db1.From = 0;
            db1.To = 1;
            db1.Duration = new Duration(TimeSpan.FromSeconds(20));
            Storyboard.SetTarget(db, myBrush1);
            Storyboard.SetTargetProperty(db, RadiusY);
          //assigning both double animation to main Storyboard
            sb.Children.Add(db);
            sb.Children.Add(db1);
            myBrush1.Resources.Add(storyboard);
            sb.Begin();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文