michaelscodingspot / WPF_MVVMC

A WPF framework for navigation between pages with MVC-like pattern
MIT License
64 stars 18 forks source link

View and ViewController destructor #8

Closed LucaFagan closed 5 years ago

LucaFagan commented 5 years ago

Hi, when GoBackCommand is invoked are the top view and associated view model destroyed ?

For example, if view1 is initial view and I navigate to view2, when I go back to view1, is view2 destroyed and when ? I have made same tests and destructors are never called.

michaelscodingspot commented 5 years ago

Hi,

The history does not save instances, just page names (strings), so when navigating back the initial view is destroyed. Try forcing garbage collection with

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
LucaFagan commented 5 years ago

Hi, you are right, forcing GC destructors are fired.

Thanks for the reply.