Should I create a new Region behavior?

Topics: Prism v2 - Silverlight 2
Apr 27, 2009 at 11:29 AM

I need a region that animates (slides) into required size when a view is added. When all views are removed, the region should slide back to collapsed state.
Any hints on how to start?

Regards larsi
Apr 29, 2009 at 8:14 PM

 Hi Larsi,


Although I do not know your exact scenario, the Stock Trader Reference Implementation has some similar functionality. Basically, when you click on the Buy/Sell buttons, a new view is added to an empty region (we will call it Region0) in the Shell. This view has nothing more than a Region (we will call it Region1) and two buttons. Region0 becomes visible when a view has to be added to Region1, and stops showing it when Region1 is emptied of views. You can check the OrdersController class to see how this is done.


Perhaps, with a similar approach but using an animation you could be able to achieve your requirement.


Another approach could be using a region Behavior. As you probably know, there is no out-of-the-box way to be aware in the Shell (which is the control that has the regions usually), when a view has been added/removed from a region. Therefore, as you mentioned, you could create a custom RegionBehavior that enables you to do this.


The following article in the Prism-v2 documentation provides more details about RegionBehaviors and how to create custom ones:

·         UI Composition


Please let me know if this helps.


Damian Schenkelman