Hey, where did IRegion.MoveFrom go?

Topics: Prism v4 - WPF 4
Feb 27, 2012 at 1:57 PM

I was using the new IRegion.MoveFrom function in the pre-release version of Prism 4.1, but I notice it's disappeared from the final 4.1 release. Is there a good reason for this (i.e. a known problem)?

I'm going to go down the route of putting it back in by hand, which sadly means editing the Prism source, but I'm wondering if there is a problem with this function of which I am not aware, which would make me reconsider.



Feb 28, 2012 at 4:59 PM

Hi Mark,

As far as I know, the MoveFrom method included in the pre-release version of Prism 4.1 was initially designed as an approach to support the scenario described in the following work item: UpdateRegionsException when adding/removing a view with a scoped region manager.

However, based on my understanding, it seems that the pattern & practices team decided to remove the MoveFrom method in the final release, as this approach didn't appear to actually solve the issue described in the work item.

If you believe that the MoveFrom method included should be included in Prism as out of the box, you could create a work item in the issue tracker or comment the aforementioned work item, so that the team can consider it for future releases.

I hope you find this useful,

Damian Cherubini

Feb 28, 2012 at 5:39 PM

It's interesting that it's been removed, because it did provide a solution for my specific case (moving views with scoped region managers between regions).

What the MoveFrom function gave us was effectively a limited way to insert a view which already has a region manager attached to it. This is all I really need to achieve. I'd favor a more generic function - i.e. an AddViewWithRegionManager() or similar.

Previously I was using my workaround to the RegionManagerRegistrationBehavior (mentioned in the thread you linked to above) to prevent the re-assignment of region managers which happens when a view is reinserted from blowing up. However, it's much cleaner in operation if we don't have to re-create a region manager at all, when the view is put back in, as there are quite a lot of knock on effects in other extensions I have to Prism when this happens.

I'm happy to write extensions to Prism, but when we start modifying the source code it becomes much harder to upgrade in the future. Honestly, I'm debating whether to splurge out some Reflection code to invoke Region.InnerAdd()...