ReInitializing

Apr 13, 2011 at 3:14 PM

Hi Horrik,
thank you for the fix #6473 issue.

But i am getting some strange behaviour.After Unload WelcomePageView and after closed ViewModel 'WelcomePageViewViewModel'

*removes WelcomePageViewViewModel from ManagedViewModel
*Unloads 'SelectLanguagePageView' and closes its viewmodel 'SelectLanguagePageViewViewModel' (before not shown)
*removes SelectLanguagePageViewViewModel from ManagedViewModel
*Loads 'WelcomePageView' again
*Adds WelcomePageViewViewModel to ManagedViewModel
*Initializes WelcomePageViewViewModel (so OnInitilialize runs second time.)
*Loads 'SelectLanguagePageView' and initilize the SelectLanguagePageViewViewModel

 

while switching from WelcomePageView tab to SelectLanguagePageView tab,  'WelcomePageViewViewModel' reinitializes


is there anything wrong here . You can find the Logs.txt as attached in #6473 issue.

Coordinator
Apr 13, 2011 at 9:00 PM

I have re-opened the ticket, will take a look at it.

Coordinator
May 7, 2011 at 8:38 AM

This behavior is by design (a view-model is initialized when a user control is loaded, and closed when a user control is unloaded). You have 2 options:

1) accept this behavior, because you never know when the user control is closed for the last time (this is why it is implemented this way)

2) handle the creation of the view-model yourself. This is how other MVVM frameworks handle this problem (which is not a clean solution, but it works)