Region context set to NULL when remove any view in region

Topics: Prism v4 - WPF 4
Sep 22, 2011 at 8:04 AM

Hi, I attached a sample project here.


Please look at \ViewModels\ShellViewModel.cs, breakpoint at line 52 which remove view from region.


After line 52, the Context property for 'GroupLayoutArea" region will become NULL value.


Ok, I have a region which have several active views, and I using Region Context above to pass data from Region down to all Views.

The problem is whenever any view is removed from that Region, the Context property of the Region will become NULL and hence other views will failed to get the region context later on.


Is there any way to remain the region context so it still able to share the data with other views under same region when a view is remove from the region?


The last choice in my mind is use Shared Services, hmmm but just post this question here to see if any solution for me.



Sep 22, 2011 at 2:15 PM
Edited Sep 22, 2011 at 2:17 PM


This is a known issue in Prism, as you can check in the following threads and work items:

We were able to reproduce the scenario you're mentioning, and we created a blog post explaining a possible workaround for this issue that does not imply having to recompile the Prism Library:

Prism v4: RegionContext lost when removing a view from a region

I hope you find this helpful.

Guido Leandro Maliandi

Sep 23, 2011 at 2:40 AM

Hi GuidoMaliandi,

Thanks for the workaround, it work for the sample I attached here.


The fixed seems disable the changes of region context when a view removed, I think this is good for other views which bind to region context data.


I will give it a try in my project and let you know the outcome.


Thanks a lot.

Sep 26, 2011 at 9:36 AM

Hi GuidoMaliandi,

The fix work well in my project, thanks again !!