How to dispose View and Viewmodel with CreationPolicy.NonShared

Topics: Prism v4 - WPF 4
Jun 17, 2015 at 2:35 PM
Hi All,

I am building a wpf app with prism 4.0 as well as MEF.

Sample code like below:


public partial class ModuleBuildingApprovalView : UserControl, IView, INavigationAware
public class ModuleBuildingApprovalViewModel : BaseViewModel
The problem is each time the view is opened, it's not disposed by GC after it's closed, that may cause big memory leak. Any good way to dispose the view and viewmodel manaully in code?
Jun 17, 2015 at 2:41 PM
By the way, i searched on website and found a couple of discussion related, like below two:

However, my view and viewmodel are not disposed anyway even i use above two solutions, my view and viewmode is opened as child region of main app container, meanwhile they contains a series of child view/viewmodels. could anyone help me out? thanks in advance.