15,670,852 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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();
}