I'm working on a WPF application based on the Microsoft Prism framework. One aspect of the application uses an ItemsControl region. I can add views to the ItemsControl by RequestNavigate-ing a view to the region. However, I don't see a way to RequestNavigate away from the region, i.e. so that the view is removed from the region and the "OnNavigatedFrom" callback is fired in the view's ViewModel.
The only way I've seen to remove a view from an ItemsControl region is to manually remove the view from the region like so:
IRegion myRegion = _regionManager.Regions["MyRegion"];
myRegion.Remove(viewToRemove);
This won't work for me, unfortunately, because I need the OnNavigatedTo and OnNavigatedFrom callbacks to be fired when the view is added to/removed from the region.
Am I missing something? Is there a way to RequestNavigate a view away from a region?
IsActiveproperty set totrue. So ideally aRequestNavigateFrommethod would remove the view from the region, setIsActiveto false, and fire theOnNavigatedFromcallback. - Nathan FriendItemsControlregion just adds the view to the region; it doesn't remove or replace an existing view. - Nathan Friend