Jaa


RandomTransitionSelector

I meant to blog about this Monday night when I wrapped it up, but it was after midnight and I was too tired.

In Transitionals, any control that supports a transition (like TransitionElement or SlideShow) can take accept a single Transition through the Transition property. They can also accept a transition strategy through the TransitionSelector property. This works in much the same way as TemplateSelector works for selecting data templates.

One thing I found very common in the projects I've written is the need to randomly pick from a list of transitions each time a transition occurs. I'd written this code custom from the SlideShow, but I decided to package this up as a TransitionSelector and modify the SlideShow to use it. I think it works quite well.

Here's the current syntax:

<transc:TransitionElement.TransitionSelector>
   <trans:RandomTransitionSelector>
      <transt:DoorTransition/>
      <transt:DotsTransition/>
      <transt:RollTransition/>
      <transt:RotateTransition/>
   </trans:RandomTransitionSelector>
</transc:TransitionElement.TransitionSelector>

This class could be extended (and probably should be extended) to allow it to pull in all the transitions from a specified assembly or set of assemblies. That would allow it to use all transitions without having to explicitly list each one. Of course, selecting transitions in this way would mean that only the default values for each transition could be used.

** UPDATE **

As of 3/16/2008, support was added to allow the load of transitions from assemblies. I even came up with a good solution to requiring default values. This is covered in the Getting Started document which is part of the chm file in the 1.0 release.