My Window will not be garbage collected if it has a child of type FormulaEditorDialog.
For a simplified example call the following two event handlers on buttons of any dialog.
WeakReference _WeakRef = null;
private void OnCheck(object sender, RoutedEventArgs e)
{
GC.Collect();
GC.WaitForPendingFinalizers();
if(_WeakRef.IsAlive)
throw new Exception("Window alive!");
}
private void OnDialog(object sender, RoutedEventArgs e)
Window dlg = new Window();
dlg.Content = new FormulaEditorDialog(); // with this line dlg lives forever
_WeakRef = new WeakReference(dlg);
if(dlg.ShowDialog() == true)
The window will stay alive, if it has content of type FormulaEditorDialog.
Do you have any workaround or solution for this problem?
TIA
Michael
Hello Michael,
Thank you for your post.
I have been looking into it, but it seems like I am missing something from your scenario, so if this is still an issue for you, could you please send me, an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward to hearing from you.
I have attached a small sample demonstrating the Problem.