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

New Post: ItemsControl + NavigationRequest

$
0
0
Hi Peter,

After checking your code I believe the "problem" you are experiencing is related to when you are setting the keepAlive attribute of the views. Basically, the OnNavigatedFrom method is only executed in the view that is being "navigated from" or in other words, in the currently active view before the NavigationRequest. For example, if you have the following views in the TabControl and you navigate to an OtherView:
  • ListView
  • EditView(1)
  • EditView(2) <-- Selected view
The OnNavigatedFrom will only be executed in the EditView(2), so only its keepAlive attribute will be changed to false while the others will keep being true. This is why only the visible view is being removed. Therefore, it doesn't seem that this approach will be effective to achieve the functionality you are looking for.

If you wish to "clear" the region when you inject a view from a different module, a possible approach could be to keep track of what module is being used and before navigating to a view from another module, remove all the views in the region. There are several approaches you can follow to do this. For example, you could use the EventAggregator and subscribe all the views (i.e. ListView, EditView, etc) to a certain event, so that in their corresponding handlers, they change the keepAlive attribute to false. Hence, before navigating to the other view, you can publish this event to set all the KeepAlive properties off all the views to false so that they are removed as expected.

I hope this helps,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Viewing all articles
Browse latest Browse all 1878

Trending Articles



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