Aug 4, 2014 at 2:20 PM
Edited Aug 4, 2014 at 2:37 PM
How can I reset my viewmodel when the user clicks new button?
If I have a view NewCustomer and upon save, the data is saved to the DB and the newly created account number is displayed. But when the user clicks the New button in the screen, I want the view to be reinitialized. Or for that matter if the user clicked Cancel
in the screen to clear all changes.
How can I achieve this? I am using Unity as my container.
Here is my quick intro of view and viewmodels that I am using:
Top Region - Menu
Main Region - Main content
Bottom Region - Status Bar control
The main content is shown using the following view and viewmodels
Home - HomeViewModel
NewCustomer - NewCustomerViewModel
CustomerSearch - CustomerSearchViewModel
I use IRegionMemberLifetime in NewCustomer and set to false upon save. So when the user navigates away and returns, I can reset the viewmodel. I will implement INavigationAware to prompt to save changes if needed.
But I can't figure out how I can reset the viewmodel when I click the New button in the NewCustomer view itself.
I have my IRegionManager only in the Module initializer class. I use regionmanger.requestnavigate to navigate in the main region between views.
Thanks for your help and input. Note: I am using Prism 5.0