I'm currently writing an application which has multiple Windows which can be dynamically created, destroyed and recreated by the user. I noticed that the first instance of a Window is kept in memory until the application is destroyed, meaning that I will
often have two instances of the same Window in memory at any one time.
After a bit of hunting I've tracked this down to ParentChangedNotifierHelper.cs in the WPF Localization Extension. In the GetValueOrRegisterParentNotifier<T> a reference to the first instance of the view is added in the following block...
parentNotifiers.Add(target, new ParentChangedNotifier((FrameworkElement)depObj, () =>
This reference hangs around forever and so the first instance of the view is never unloaded from memory.
I've reproduced the issue in very simple application (code available if needed). The application simply creates an instance of a view containing a localized Label.
Am I doing something wrong? Is there any way I can work around this?
Any help would be much appreciated!