I remember someone wrote about snow in the blog Park.ProgramToday is Christmas Eve. Let's see how the snow works:
Blend BehaviorCodeAs follows:
Public class Fallingsnowbehavior : Behavior < Canvas > {Private Static Random Randomnumber; Protected override void Onattached (){ Base . Onattached (); randomnumber = New Random (); This . Associatedobject. Loaded + = New Routedeventhandler (Applicationloaded );} Void Applicationloaded ( Object Sender, Routedeventargs E ){Foreach ( Frameworkelement Element In this . Associatedobject. Children ){ Frameworkelement Localcopy = element; Double Yposition = Canvas . Gettop (localcopy ); Double Xposition = Canvas . Getleft (localcopy ); Double Speed = 2 * randomnumber. nextdouble (); Double Counter = 0;Double Radius = 30 * speed * randomnumber. nextdouble (); localcopy. Opacity = 0.2 + randomnumber. nextdouble (); Compositiontarget . Rendering + = Delegate ( Object O, Eventargs Arg) {counter + = Math . PI/(180 * speed ); If (Yposition < Application . Current. rootvisual. desiredsize. Height) {yposition + = 0.2 + speed ;} Else {Yposition =-localcopy. height ;} Canvas . Settop (localcopy, yposition ); Canvas . Setleft (localcopy, xposition + radius * Math . Cos (Counter ));};}} Protected override void Ondetaching (){ Base . Ondetaching ();}}
Source codeDownload
References
Http://www.kirupa.com/blend_silverlight/falling_snow_silverlight_pg1.htm