Fill region with view

Topics: Prism v4 - Silverlight 4
Jun 9, 2011 at 3:02 PM


I have a prism application with several views and can navigate between the views without any problems using RequestNavigate(...).

One of my views has a grid and I would like this grid to fill the entire region.

I have read that you can replace ContentControl with an ItemsControl as follows:


I have done this but when I navigate between the views, the views are now displayed on top of each other.

Each of the views implements IRegionMemberLifetime and returns false for KeepAlive property.

Each of the view model and model types are registered with unity container using TransientLifetimeManager.


Jun 9, 2011 at 6:38 PM


The reason your views are placing one on top each other is because you are using an ItemsControl which region defined by it region adapter is an AllActiveRegion. In your case you should use the ContentControl to place your views, since it region adapter defines a SingleActiveRegion. A SingleActiveRegion means every time you navigate between your views, only one will be display inside the region.

On the other hand, you could try setting the HorizontalAlignment and VerticalAlignment properties to Stretch value, which stretches the grid to fill the entire layout slot of the parent element. You can read about these properties here.

As this is not strictly related to Prism, you might obtain better support about how to fulfill the entire layout of a content control in the Silverlight Forums.

I hope you find this information useful.


Miguel Bronzovic

Jun 9, 2011 at 7:02 PM

Thank you for your reply.

I have tried setting the HorizontalAlignment and VerticalAlignment properties to Stretch value for both the Grid, the UserControl that contains the Grid as well as the ContentControl but the content still appears in the top left corner of the region.

I will obtain further support in the Silverlight Forums.

Jun 9, 2011 at 7:20 PM

The solution is to set the HorizontalContentAlignment and VerticalContentAlignment properties of the ContentControl to Stretch value.

Thanks again for your help.

Jun 9, 2011 at 7:26 PM


Thank you for share this with the rest of the community, as other users might benefit from knowing this.

Miguel Bronzovic