Project Description
A modal control for Silverlight 3 (same code can be used in Silverlight 2) that uses different animations to present a given control and lock out the rest of the application.

This control allows a given control to be presented to the user while locking out the rest of the Silverlight controls (basically, a modal control).

The name "ScalingModal" comes from the original scaling animation that was used with the control. Since then, many other animations have been added.

The ScalingModal can be initialized with a reference to a ContentControl that will be disabled when the modal is expanded. The ContentControl should usually be wrapped around as much of the Silverlight application as possible so that tabbing, controls, etc. will be prevented from being accessed by the user when the modal is expanded.

As far as using it, the ScalingModal is a singleton that just needs to be initialized at startup by passing in its parent control along with the optional ContentControl to be disabled as specified above. Then, whenever it needs to be expanded, you just call the static Instance's Expand() method and pass in the control you want to be presented. To collapse the modal, you just call the Instance's Collapse() method. Specific animations can be used per use by an optional parameter on the Expand() and Collapse() methods, or specified globally by setting the Instance's Animation property (the default is to use a random animation).

Since this control was originally developed (in Silverlight 2), the ChildWindow control has been released in Silverlight 3. A quick list of the differences between ScalingModal and ChildWindow are as follows:
  • ChildWindow automatically takes care of disabling the rest of the Silverlight application; in the ScalingModal, you need to wrap the parts of the application with a ContentControl to disable upon modal expansion.
  • I've noticed some controls don't work as expected when used in the ChildWindow. For example, the Silverlight Toolbox's drag-and-drop control wrappers don't seem to work in ChildWindows, but they do work in ScalingModals.
  • The ScalingModal control gives you many animations and control over how dark the rest of the application gets when the modal is expanded. The control can be extended with more animations.

For examples of this control in action, see the following pages:
    • Picture pages use the scaling modal control when presenting the full-size version of a picture.

Last edited Feb 16, 2012 at 10:53 PM by hiryu, version 5