Prism - Region adpater for content control

Topics: Prism v4 - Silverlight 4
Feb 15, 2012 at 9:45 AM
Edited Feb 15, 2012 at 9:48 AM

I have silverlight application using Prism and I am using ContentControl as a region something like below

In some rare cases the application is throwing an exception "This control is being associated with a region, but the control is already bound to something else".

I checked the prism library and it is throwing this error from ContentControlRegionAdapter.Adapt method. In this method it is doing following checking

if (regionTarget == null) throw new ArgumentNullException("regionTarget"); bool contentIsSet = regionTarget.Content != null; if (contentIsSet) { throw new InvalidOperationException(Resources.ContentControlHasContentException); }

In which scenario contentIsSet will be true? Also is there any issue if I remove that condition and set the view to the
content directly?

Feb 15, 2012 at 1:21 PM


Based on my understanding, this exception might be caused if you set the content property of the control that contains the region. In Prism you are not allowed to associate a control with content and a region, as the content registered within that region will be loaded there at run time, hence you will probably have issues if you remove that condition and defined additional content in your control. By design controls associated to regions should be kept as empty containers.

If you are interested, you could find useful information about Prism region implementation in the following chapter of the Prism documentation:

I hope you find this useful,

Agustin Adami

Feb 15, 2012 at 3:44 PM

Hi Agustin,

 Thanks for your replay. Actually we are not setting the content manually.Is there any chance that the Prism will call the adapter method twice to set the content?

Feb 16, 2012 at 1:14 PM


So far, I haven't seen  a similar issues reported so far. It could be helpful if you could provide us with more information about your scenario or a repro sample, so that we can help you further with this.


Agustin Adami