WPF/E Tests

A selection of examples made in my first encounter with WPF/E (codename).

NOTE:

These examples require the WPF/E plugin (for PC) (or plugin for Mac).

Download full source code (to compile or develop yourself, you require the following tools.)

Tips and Tricks

I'd like to cover a couple of quick tips and tricks when working in WPF/E

3 Ways to Animate

  1. Storyboards - Use this in the XAML to perform a variety of transformations on opacity, scale, rotation etc for individual or groups of elements. This is the most efficient way to animate elements, but not always the most flexible so a balance is good.
  2. Javascript "onTick" - In my examples you will see I use an onTick function quite a bit. This is called when a 0 second Storyboard completes. This is very flexible, because you are using your own math/logic to animate things in a very dynamic way (see the snowflakes in the Winter Card), the downside is that JavaScript is not very fast, so be careful.
  3. Javascript - Just using setInterval in JavaScript or animating things whenever you feel like it is the best way to crash the app and throw an error. The WPF/E control just might not be ready for you to act, so stick to onTick if you are doing a lot of continuous (non event based) animation.

createFromXaml() - Add elements before using them...

Remember to add your XamlElement to another’s Children array before trying to access properties on it.

This will not work…

var myXamlCar = myWpfe.CreateFromXaml( someXaml );
myXamlCar.Opacity = 10;
myMainXamlCanvas.Children.Add( myXamlCar );

This will…

var myXamlCar = myWpfe.CreateFromXaml( someXaml );
myMainXamlCanvas.Children.Add( myXamlCar );
myXamlCar.Opacity = 10;
This is something I am told will be fixed shortly.

Utility Classes

In the zip above I have included a lot of JavaScript which is documented. Particularly in the /util and /xaml folders. Feel free to use this to speed up your development.