A four stroke engine in Silverlight

I decided to try out Expression Blend 2.5 beta by creating a four stroke engine animation. A screen capture is shown below:
engine

You can see a working demo here (Silverlight 2 plugin required)

Here are a few observations while working on this project.

  1. Writing XAML by hand is difficult :-) Expression Blend is your friend.
     
  2. To export Adobe Illustrator files to XAML, use the free plugin from Mike Swanson. I chose to use AI to create the vector art because I am familiar with AI and it has a lot more features than Expression Design. When importing the XAML into Blend, you might see error messages in Blend about invalid markup as a result of the translation. In most cases these errors can easily be fixed by editing the XAML markup (Blend gives you the line number of the error).
     
  3. For performing simple custom animations using a timer in your UI thread, use the DispatcherTimer class. The timer raises a Tick event at the end of the specified interval where you can update the UI. Note that the DispatcherTimer is single threaded and does not use the thread pool which could lead to a frozen UI if the Tick event handler takes too long to complete or if the thread is busy doing something else.
     
  4. To apply multiple transformations to an object, for example a RotateTransform and a ScaleTransform at the same time, use the TransformGroup class.
     
  5. Expression Blend,  AFAIK, does not allow you to edit your C# files. You edit them in VS 2008. Be prepared for a lot of switching back and forth between both applications. In addition, VS 2008 sometimes goes crazy and refuses to show you the XAML preview when you have a complex XAML document. Restarting VS or recompiling the project usually makes the problem go away. Probably because I am using a beta product.
     
  6. Animations can be created in expression blend using a timeline where you set keyframes that define the start and end points of the transform on an object. I chose, instead, to create the animations in code behind using C# using mathematical equations.

Overall, Expression Blend 2.5 beta was easy to work with. The UI could be improved a lot though. I plan to post feedback on Microsoft Connect soon.

You can download the VS 2008 project here or from the mirror here.

4 Comments

Comments have been disabled for this content.