0

我需要将此 xaml 代码转换为 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>
4

2 回答 2

1
Storyboard sb = new Storyboard();
sb.BeginTime = TimeSpan.FromSeconds(10);
sb.Children.Add(new DoubleAnimation());
sb.Children.Add(new DoubleAnimation());
于 2011-08-09T16:32:05.020 回答
1
            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();
于 2012-09-24T13:44:48.300 回答