Hi Brew,
Basically, Prism's Regions work differently depending on the control they are being adapted to. In this particular case, we have two different regions types: the SingleActiveRegion (for ContentControls) and the AllActiveRegion (for ItemsControls).
When you where using an ItemsControl, you had an AllActiveRegion, which basically is a region that never deactivates its views, and therefore, all its views will be considered active. In such scenario, the IRegionMemberLifetime will not work, as it's only used when a view in the region is deactivated (which never happens in an AllActiveRegion).
Then, when you changed to a ContentControl, you had a SingleActiveRegion, which is a region that only allows one view to be active at the same time; all the rest of the views in the control are deactivated. In this case, the "visible" view in the control will be the active one, meaning the deactivated views will not be shown (but will be stored inside the region instance). In this scenario, the IRegionMemberLifetime is used when a view is injected or activated as the previous one will be automatically deactivated.
Take into account that the default behavior in Prism for views / view models that do not implement the IRegionMemberLifetime interface or attribute is to keep the view alive (as if they had the KeepAlive property set to true). Hence, in a ContentControl, when injecting such a view, the previous view will not be visible but will be kept alive in the region, consuming resources. If those views / view models had the KeepAlive property set to false, they would not only be removed from the control but also from the region completely upon deactivation.
I hope this helps,
Damian Cherubini
http://blogs.southworks.net/dcherubini
Basically, Prism's Regions work differently depending on the control they are being adapted to. In this particular case, we have two different regions types: the SingleActiveRegion (for ContentControls) and the AllActiveRegion (for ItemsControls).
When you where using an ItemsControl, you had an AllActiveRegion, which basically is a region that never deactivates its views, and therefore, all its views will be considered active. In such scenario, the IRegionMemberLifetime will not work, as it's only used when a view in the region is deactivated (which never happens in an AllActiveRegion).
Then, when you changed to a ContentControl, you had a SingleActiveRegion, which is a region that only allows one view to be active at the same time; all the rest of the views in the control are deactivated. In this case, the "visible" view in the control will be the active one, meaning the deactivated views will not be shown (but will be stored inside the region instance). In this scenario, the IRegionMemberLifetime is used when a view is injected or activated as the previous one will be automatically deactivated.
Take into account that the default behavior in Prism for views / view models that do not implement the IRegionMemberLifetime interface or attribute is to keep the view alive (as if they had the KeepAlive property set to true). Hence, in a ContentControl, when injecting such a view, the previous view will not be visible but will be kept alive in the region, consuming resources. If those views / view models had the KeepAlive property set to false, they would not only be removed from the control but also from the region completely upon deactivation.
I hope this helps,
Damian Cherubini
http://blogs.southworks.net/dcherubini