Confused by removal of PanelRegion

May 18, 2008 at 9:22 PM
I'm just starting to upgrade my code to the latest drop and I've run in to a snag with Panel based controls and making them regions.  The release notes say...

Region adapters are classes that know how to manage the content of a particular WPF control, and they bind the content of WPF container controls to the views that a SimpleRegion instance holds. New region adapters were introduced: ContentControlRegionAdapter and ItemsControlRegionAdapter. The ContentControlRegionAdapter manages ContentControl controls, and the ItemsControlRegionAdapter manages ItemsControl controls.

However, a Panel is neither a ContentControl nor an ItemsControl.  So with the remove of the PanelRegion, you've taken away the ability to make any Panel derived object a region.  Was this intentional?  An oversight?  An error?  Do you intend for us to have to write out own IRegion and IRegionAdapters everytime we need a region based on a Panel?

Thanks for any feedback.
May 20, 2008 at 4:36 AM
Edited May 20, 2008 at 4:48 AM
I have just come across the exact same issue. I am attempting to write my own RegionAdapter, the problem being their is no assignable Content/Children/Whatever property. I would love to know what the official stance is on this.
May 20, 2008 at 4:47 PM
Ditto here.  I started switching my Panels over to ItemsControls and for the most part everything is ok (in my scenario).  But I'm having weird layout issues with the ItemsControls, they aren't behaving like Panels which is to be expected.
May 22, 2008 at 11:11 PM
The idea behind the removal, is that you could use panels as a layout detail of an ItemsControl, but can still always use ItemsControl as the UI element for the region. So for example, if you'd like to use a WrapPanel as a region, you could use the following markup:

        <ItemsControl prism:RegionManager.RegionName="MainToolbarRegion">
                    <WrapPanel />

With this approach, do you reckon there might be scenarios where this is not enough and where an out-of-the-box PanelRegionAdapter would still be needed?

Julian Dominguez
May 23, 2008 at 12:54 AM
Yes,  I'm extending a third party control to be a region.  The control is based on a panel.  I'm not actually setting things up in the XAML markup so I can't do the above, and the control takes a collection of things based on a panel.

Not that writing a PanelRegion was hard, but the above solution just doesn't seem obvious to me, and unless it is called out in the documentation, there's no way I would ever figure that out and would end up writing  my own region.
May 23, 2008 at 7:28 PM
I also think this is unclear and that a PanelRegion should be included in the framework. The ItemsControl solution suggested for using a Panel region is inelegant and a hack, IMO.

The way I am currently getting around the change is by using :
<ContentControl prism:RegionManager.RegionName="{x:Static infrastructure:RegionNames.Toolbar}"/>
And inserting a UserControl based View into the region. Almost all of my regions will be Panel based.