Click here to Skip to main content
15,881,898 members

Comments by greendragons (Top 3 by date)

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

and
.cs file

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

public MainWindow()
{
InitializeComponent();


}

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);
starPoints.Add(Ty);
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);

MyCanvas.Children.Add(es);

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));

MyStoryBoard.Children.Add(dAnim);

}


}

private void MyCanvas_Loaded(object sender, RoutedEventArgs e)
{
CreateRandomStars();
}

}
greendragons 9-Mar-11 23:30pm View    
this is the link.... http://jumbofiles.com/vq0v7vorhfip
And yes stars are showing up...but i want them to move from their original Canvas.top position to
the bottom limit of canvas....tht is why im using DoubleAnimation...
Thnx!
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)
{
CreateRandomStars();
}