views:

47

answers:

2

This is perhaps a silly question, but I can't seem to find out how to do this.

I have a Silverlight app using Prism's regions, and I have a requirement for an 'expand'-type button inside one of my views. When the user clicks that button, I need the view to grow larger.

How do I change the size of my region dynamically, like this?

I've fooled around with setting the Height/Width properties of my view, and even grabbing ahold of my view's Parent (which is the region, in this case -- a ContentControl) and setting it's Height/Width properties, to no avail.

+2  A: 

I have multiple views in a grid and have no problem changing the size of rows or columns dynamically to vary the content. That probably means that you need to be changing the size of the parent of the ContentControl, rather than the content control itself.

The only requirement I found was that HorizontalAlignment="stretch", VerticalAlignment="stretch" HorizontalContentAlignment="stretch" and VerticalContentAlignment="stretch" all need to be set on content controls (to stop the content collapsing).

Enough already
Thanks. Yep, it was a silly question. In this case I didn't have the controls *inside* my view set to stretch, but the solution was the same.
Craig Vermeer
+1  A: 

Hi,

Prism regions are simply an abstraction over the Content/Items/Selector controls. That said, to be able to change size of a region you should do as with any other control. One possible approach as HiTech Magic said, could be setting HA and VA to stretch. Additionally, you could set the Height and Width properties of the ContentControl to Auto.

Doing that will enable you to increase the size of regions automatically as the size of the view increases as well.

You can read about a similar example of this here: http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=68800

I hope this helps.

Thanks, Damian

Damian Schenkelman