Click here to Skip to main content
15,670,852 members

Comments by greendragons (Top 3 by date)

greendragons 10-Mar-11 9:09am View    
I have changed to
EventTrigger RoutedEvent="Canvas.Loaded"

.cs file

public partial class MainWindow : Window
public List<double> starPoints = new List<double>();

public MainWindow()


public void CreateRandomStars()

int Width = (int)MyCanvas.Width;
int Height = (int)MyCanvas.Height;

Random Rnx = new Random(0);

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

double Lx = (double)Rnx.Next(Width);
double Ty = (double)Rnx.Next(Height);
Ellipse es = new Ellipse();
es.Name = "es_" + i.ToString();
es.Width = 2;
es.Height = 2;

es.Fill = Brushes.WhiteSmoke;
es.SetValue(Canvas.LeftProperty, Lx);
es.SetValue(Canvas.TopProperty, Ty);


DoubleAnimation dAnim = new DoubleAnimation();
dAnim.From = Ty;
dAnim.To = Height;
dAnim.Duration = new Duration(new TimeSpan(0, 0, 5));
//dAnim.SetValue(Storyboard.TargetNameProperty, es.Name);
dAnim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Canvas.TopProperty));




private void MyCanvas_Loaded(object sender, RoutedEventArgs e)

greendragons 9-Mar-11 23:30pm View    
this is the link....
And yes stars are showing up...but i want them to move from their original position to
the bottom limit of canvas....tht is why im using DoubleAnimation...
greendragons 9-Mar-11 23:07pm View    
Sorry im new to WPF,
Im still getting error, even i changed ma XAML...maybe im making the call from wrong place...

private void MyCanvas_Loaded(object sender, RoutedEventArgs e)