Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: How to instantiate a new view/view-model each time it is navigated to?

$
0
0
I'm using Prism 4 navigation, and Castle Windsor. I'm a bit unclear on view lifetime, and how to instantiate a new view each time I navigate to it. I've implemented the following:-
  • Register the views/view-models with Windsor as "transient"
  • Mark the view-models with attribute "[RegionMemberLifetime(KeepAlive = false)]"
Sure enough, each time I navigate to a view using "regionManager.RequestNavigate()", the constructor gets called, confirming that a new view is instantiated each time. But what happens to the "old" views? I'm finding that they are still responding to events published from my "event aggregator" service, so am I responsible for clearing up these old/inactive views, and if so how?

Lastly, one of my views has nested regions/views - assuming I've configured these views as above, will they be destroyed when the parent view gets destroyed?

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>