locked
Run time controls and run time Storyboard RRS feed

  • Question

  • I created storyboard by code in run time, and also another control ,I want this story see my control but ,it's not.

    I have this error

    'MY_Rec0' name cannot be found in the name scope of 'System.Windows.Controls.Canvas'

    This is C# code

    for (int i = 0; i < 3; i++)

                {

                     Rectangle exampleRectangle = new Rectangle ();

                    exampleRectangle.Width = 75;

                    exampleRectangle.Height = 75;

                    // Create a SolidColorBrush and use it to

                  //   paint the rectangle.

                    SolidColorBrush myBrush = new SolidColorBrush (Colors .Aqua);

                    exampleRectangle.Stroke = Brushes .Red;

                    exampleRectangle.StrokeThickness = 4;

                    exampleRectangle.Fill = myBrush;

                    exampleRectangle.Visibility = Visibility .Hidden;

                    exampleRectangle.Opacity = 0;

                    exampleRectangle.Name = "MY_Rec" + i;

                    canvas.Children.Insert(i, exampleRectangle);

                    Canvas .SetLeft(exampleRectangle, i*100);

                  

                }

     

                Storyboard C_ST = (Storyboard )canvas.FindResource("fade" );

               

                DoubleAnimationUsingKeyFrames DA = new DoubleAnimationUsingKeyFrames ();

     

                SplineDoubleKeyFrame SD = new SplineDoubleKeyFrame ();

                SD.KeyTime = new TimeSpan (0, 0, 0);

                SD.Value = 0;

                DA.KeyFrames.Add(SD);

              

                

                SplineDoubleKeyFrame SD2 = new SplineDoubleKeyFrame ();

                SD2.KeyTime =  new TimeSpan (00,00,Convert .ToInt32(00.4000000));

                SD2.Value = 1;

                DA.KeyFrames.Add(SD2);

     

                C_ST.Children.Add(DA);

              

                foreach (Rectangle rec in this .canvas.Children)

                {

                    DA.SetValue(Storyboard .TargetNameProperty, rec.Name);

                    C_ST.Begin(canvas);

                }

    Wednesday, August 19, 2009 11:59 AM

All replies