WHY DOESNT PRISM WORKIN MY MASCHINE LIBRARY CODE
I was able to even step this code to see how it interacts with my application. RegionMemberLifetimeAttribute lifetimeAttribute = GetItemOrContextLifetimeAttribute(inactiveView) IRegionMemberLifetime lifetime = GetItemOrContextLifetime(inactiveView) Private static bool ShouldKeepAlive(object inactiveView) If (e.Action != Notif圜ollectionChangedAction.Remove) return įoreach (var inactiveView in inactiveViews) unless we wanted to start tracking views that used to be active. always raise a remove and we don't handle any resets Thus, we expect that any ICollectionView implementation would We only pay attention to items removed from the ActiveViews list. Here's the code that is relevant: private void OnActiveViewsChanged(object sender, Notif圜ollectionChangedEventArgs e) It would be useful for you to look into the RegionMemberLifetimeBehavior class in the Prism Library (for me, it is at C:\Prism4\PrismLibrary\Desktop\Prism\Regions\Behaviors)īoth the IRegionMemberLifetime interface and the RegionMemberLifetimeAttribute accomplish the same thing and can be defined on either your View or your ViewModel (provided the viewmodel is set to DataContext). Public MainViewModel(IUnit圜ontainer container, IRegionManager regionManager) Private readonly IRegionManager _regionManager Private readonly IUnit圜ontainer _container Public class MainViewModel : ViewModel, IMainViewModel I am implementing IRegionMemberLifetime on the View and setting KeepAlive to false so that I always get a new instance of the View and the ViewModel.īut for some reason, when I click on the Navigation Button, my breakpoint at KeepAlive never reaches and I get the MainView instead of the WelcomeView. I have implemented the switching logic in the constructor of the ViewModel I have a need to switch the view being displayed based on a certain condition.