ViewWrapper - Runtime View Uniform Behavior

Topics: Prism v4 - Silverlight 4
Dec 8, 2010 at 3:57 AM

In the StockTraderRI, popup is implemented with PopupWrapper attached to DialogActivationBehavior. I really like this behavior because it gives any popup with the same behavior (close button, style).

Within my application, views can be added and activated to MainRegion. I want all these view to have uniform behaviors, which means they should have close button, resize button, and style as well. The reason I'm considering the popup example in StockTraderRI is because it has the flexibility to convert any UserControl (view) to receive these behaviors.

I intent to use the popup behavior in StockTraderRI and apply to my case. However, I do not like to use the popup control (dealing with z-index...) as the parent container to usercontrol (view). Is there a better approach to tackle this scenario?


//PopupWrapper from StockTraderRI

private readonly Popup popUp;
private readonly ContentControl container;

public PopWrapper()
 this.container = new ContentControl();
 this.popUp = new Popup();
 this.popUp.Child = this.container;

public event EventHandler Closed
 add{ this.popUp.Closed += value; }
 remove{ this.popUp.Closed -= value; }


Dec 9, 2010 at 10:23 PM


According to your scenario, you might want to extend the DialogActivationBehavior so that instead of using the PopUpWrapper you could implement your desired wrapper for the control that you wish to use.

Take into account that Prism provides the possibility of extending its functionality through, for example by creating your own Region Behaviors. For more information you can read the following chapters of Prism´s documentation:

· Region Behavior, Chapter 7: Composing the User Interface (Region Behavior section)

· Extending Prism, Appendix E: Extending Prism

I hope this information is useful.

Miguel Bronzovic