This project is read-only.

unloading/dealloc usercontrol DataContext


It would probably be more helpful if i created a demo app and replicated the memory leak. I will try explaining my issue and if that doesnt work ill put together a demo app
1 Window
10 User controls
Window holds dynamic user controls container.... that is ..... <UserControl Content="{Binding Path = UserViewControl....
Window also has 10 buttons, each buttons swaps out the windows user control container with a control...
User controls are loaded into the window
Each user control has its ViewModel that it sets the UserControl.DataContext to. i.e.
So whats the problem?
well., I see that if i open up xUserControl which loads xViewModel, i see the program memory increase, then if i navigate to Y, i.e yUserControl which loads yViewModel i get another memory increase.. If i go back to a previously opened view model, it doesnt do increase memory again. most probably because of the autofac/ioc containers being used...
in a nutshell when i swap out usercontrols in the usercontrol container, it doesnt release the ViewModel that was set in the usercontrols datacontext....
I guess i could hook into the Unloaded method for usercontrols... but what/how do i dealloc the datacontext?
Does my question even make sense?