A couple of things that don’t (currently) work in Silverlight

I’ve just tried a couple of ‘tricks’ in Silverlight to avoid writing "code-behind" but both failed.

Using XAML triggers:
One mechanism that should work in the final version is the ability to create XAML that responds to an even and can trigger something else, such as a storyboard. This is especially useful for Designers who want to test their designs/animations without having to write procedural code. The XAML is "supported" but simply doesn’t work, you get odd messages about values been out of range. This is the idea anyway…

<Rectangle.Triggers>

<EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">

<BeginStoryboard Storyboard="{StaticResouce mystory}"/>

</EventTrigger>

</Rectangle.Triggers>

However, it’s not all bad news, you can use the above technique if you embed the stroyboard rather than using the static resource. However, this isn’t good for a Designer using Blend as currently blend "loses" the storyboard…you can’t win 😉

Embedding code into XAML:
XAML has a special inline code element, <x:Code> that you place procedural code into it. Ok so you need to write the event handler but that’s pretty close to boiler plate code so easy to copy. Plus you don’t have to leave Blend to write it. However, when I tried it Silverlight just didn’t like it and wouldn’t run the page let alone the code.
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s