I have a PRISM RegionManager with several regions - the ribbon area at the top and the main content area for my presentation below it - is pretty simple.
The application starts with a home view in the main content area. When I click the button on the ribbon, I add a second view to the content area and navigate to it in the region manager. When I click the button on this view, it should be deleted and the original view will be shown.
I am currently doing this using the RegionManager.Add () method to manually add a second view. When I want to remove it, I post an event that is consumed by the manager class that receives the current active remove, calls Remove () in the Region Manager for it, and then goes back to its original view.
All this works fine, except that when the second view remains alive after calling Remove () and saves the handle to any subscriptions that it has made in its entire life! I tried calling Subscribe explicitly with a lie for weak event references, but by default it is the default and this did not help. I tried both types of creating a view (opening and injection) and deleting a view using "Delete and Deactivate". None of them helped. This is a real problem, because when I want to create the same view in the future (a new instance of this view), I stay with several instances of them, all subscribe to the same events, although some of these instances were deleted centuries ago from the Manager region.
Do I need to manually unsubscribe from each event that I sign in my submissions (highly undesirable)? Or is there a way I can manage the control / mark it as deactivated so that its subscriptions are deleted?
I have the feeling that I'm doing something stupid here, but it completely puzzled me.
thanks
Isaac abraham
source share