A ViewModel mapped to a Window is not recreated at the 2nd window.showdialog call

Sep 24, 2011 at 8:45 PM
Edited Sep 25, 2011 at 1:23 PM

 

Hello Marlon,

I am using your latest 1.2 release of MEFedMVVM.

everything works fine: the service injecting and the viewmodel attaching for the first time I am calling my DialogService where I open the NewSchoolYearWindow and doing ShowDialog on it.

When this window is closed and I call this windows again then the ViewModel is not recreated (via debugger I cant get into the Ctor of the ViewModel) and the former data in the textboxes are still there what

I do not want at all. Somehow the window or the viewmodel seem to be reused. I tried .ViewModel/.NonSharedViewModel/.SharedViewModel they all behave the same?

What do I have to do that the ViewModel is created every time I call the window?

 

Window XAML:

xmlns:mefed="http:\\www.codeplex.com\MEFedMVVM"  

mefed:ViewModelLocator.NonSharedViewModel="NSVM"

ViewModel:

 

 

 [ExportViewModel("NSVM")]    public class NewSchoolYearViewModel : SuperViewModel
      private LightCommand _savePathOpenCommand; 
      private LightCommand _createNewSchoolYearCommand; 
      private LightCommand _openNewSchoolYearDialogCommand;
      private SchoolYear _currentSchoolYear;  
      private IProjectService _projectService;  
      private readonly IMediator _mediator;  
    
       [ImportingConstructor] 
       public NewSchoolYearViewModel(IMediator mediator, IProjectService projectService)
        {           
            _mediator = mediator;    
            _projectService = projectService;   
        }
}