I am in prism just for 2 days know, so don't judge me for any false assumptions when trying to explain the following navigaton problem.
Let's say we have just 1 region and 2 different views. View A is loaded to that region from start up by a custom RegionBehavior. All I use is RequestNavigate on the RegionManager in that Behavior. I didn't find any better solution to set the initial view but that's not the main point here.
Now we have a button on each view to navigate to the other. The commands are executed on each ViewModel and call RequestNavigate again. I used constants to register the views for navigation at the container (Autofac) and I use the same constants for calling RequestNavigate. Everything works fine on first sight. But then I realised that everytime I switch views, a new view and viewmodel is created. Even worse, the RegionManager still holds references to all the previous ones, which seems to be a memory leak. I could switch to registering my views as singleton now but I still didn't understand why the RegionManager works that way. Why doesn't he realise that he already knows a view that I request navigation for and activates that one instead of creating new ones? What else am I using constants as names for then?
Then I found this post PRISM WPF - Navigation creates new view every time and indeed this solves the problem. As soon as I use the name of the type for registering the views, everything works as expected. View and viewmodels are created on first use and are reused then when being requested for navigation again.
I could still implement IRegionMemberLifetime and return false on KeepAlive if this is not my wanted behavior and if I prefer to create new views/viewmodels each time. And then at least the former ones are erased from RegionManager. And If I don't want to erase them and still want this old memory consuming behavior, I could still implement INavigationAware and return false in IsNavigationTarget. This way RegionManager creates new instances each time and still holds references to the old ones. The other way around I can't stop him creating new instances when the registration name doesn't equal the type name. IsNavigationTarget is not even reached in that case, which tells me that the RegionManager does not look up the exisiting views at all. So why do we have 2 different behaviors here, depending on the name I registrate my view for navigation? Am I wrong when I think that the behavior that applies when both names equal should be the only one because all other scenarios can still be created with the mentioned additional properties?
steve