Expression Blend and Design

The team blog of the Expression Blend and Design products.

Creating Falling Snow in Silverlight!

Creating Falling Snow in Silverlight!

  • Comments 15

Exactly a year ago (plus one day…but who’s counting?!), I posted a sample WPF application that simulates falling snow. Since Silverlight 2 was released since then, below you will find a Silverlight version of a similar falling snow effect:

Get Microsoft Silverlight

Just click on the Let It Snow banner to cause 200 snowflakes to start falling. Feel free to use this for your own projects, and the source files have been provided below:


folderfiles Download Falling Snow Source

For your own projects, the only thing you may want to tweak is the width and height of your application. Currently, everything is hard coded to a width and height of 500px by 300px respectively, but if you decide to change the size, be sure to open Page.xaml.cs and change the dimensions provided:

private void PopulateSnowFlakes()
{
   for (int i = 0; i < 200; i++)
   {
      SnowFlake snowFlake = new SnowFlake();

      // 500 and 300 is the width/height of the application
      snowFlake.SetInitialProperties(500, 300);
      LayoutRoot.Children.Add(snowFlake);
   }
}

Besides that, everything else should be pretty straightforward. If you have any questions, feel free to leave them below.

Cheers!
Kirupa

Leave a Comment
  • Please add 6 and 4 and type the answer here:
  • Post
  • PingBack from http://www.codedstyle.com/creating-falling-snow-in-silverlight/

  • Very nice!  I'm glad you avoided the temptation to soften this up with radial gradients on the flakes... :)  It looks great.

  • Haha, thanks Robby. I don't know what I was thinking last year when I gave the snowflakes some gradients :P

  • In this issue: Maurice de Beijer, Damon Payne, Expression Blend and Design BLog, Bart Czernicki, Ning

  • Quoi de mieux qu’une bonne chute de neige pour embellir vos projets de fin d’année ? C’est ce que vous

  • Thanks for posting this!  Awhile ago I tried to create a decent looking snow animation using SL, but was unable (I'm a web designer, but only a novice C# programmer). It's nice to see how to do this!  There's lots for someone like me to learn from your code.

    I might actually reopen that project and add that snow animation in after all.

    Thanks again!

  • Открытки, как изветно, бывают самые-самые разные, поэтому сразу от слов к делу. Открытка будет вот такая:

  • Открытки, как извеcтно, бывают самые-самые разные, поэтому сразу от слов к делу. Открытка будет вот такая:

  • ok, Natal passou e a previsão é de 29 graus aqui em sampa, mas até que essa animaçãozinha cai bem&#160;

  • Открытки, как известно, бывают самые-самые разные, поэтому сразу от слов к делу

  • Exactly a year ago (plus one day…but who’s counting?!), I posted a sample WPF application that simulates

  • Открытки, как известно, бывают самые-самые разные, поэтому сразу от слов к делу. Падающий снег, мигающая звездочка, встроенные DeepZoom, несколько ссылок и открывающееся окошко с благодарностями. Исходники – в самом конце (их можно свободно использовать

  • I made the same effect about a year ago, your code is very similar to mine but both mine and yours have a slight stutter in the animation.

    I've tried it this way using the CompositionTarget.Rendering event, and also with assigning each flake a DoubleAnimation (which performs worse in terms of fp/s), both give the same stutter.

  • I made the same effect, your code is very similar to mine but both mine and yours have a slight stutter in the animation.

    I've tried it this way using the CompositionTarget.Rendering event, and also with assigning each flake a DoubleAnimation (which performs worse in terms of fp/s), both give the same stutter.

  • чтоб тебя - у тебя ничего не работает !

Page 1 of 1 (15 items)