From 23e0a718773fec3fb5a54f1759892149f3927ca9 Mon Sep 17 00:00:00 2001
From: de4dot <de4dot@gmail.com>
Date: Sun, 8 Mar 2015 15:35:00 +0100
Subject: [PATCH] Call IPane.Closed() before overwriting xxxPane.Content

---
 ILSpy/MainWindow.xaml.cs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs
index 61969f366..35bfaf87c 100644
--- a/ILSpy/MainWindow.xaml.cs
+++ b/ILSpy/MainWindow.xaml.cs
@@ -835,7 +835,12 @@ namespace ICSharpCode.ILSpy
 				topPaneRow.Height = new GridLength(sessionSettings.TopPaneSplitterPosition, GridUnitType.Star);
 			}
 			topPane.Title = title;
-			topPane.Content = content;
+			if (topPane.Content != content) {
+				IPane pane = topPane.Content as IPane;
+				if (pane != null)
+					pane.Closed();
+				topPane.Content = content;
+			}
 			topPane.Visibility = Visibility.Visible;
 		}
 		
@@ -860,7 +865,12 @@ namespace ICSharpCode.ILSpy
 				bottomPaneRow.Height = new GridLength(sessionSettings.BottomPaneSplitterPosition, GridUnitType.Star);
 			}
 			bottomPane.Title = title;
-			bottomPane.Content = content;
+			if (bottomPane.Content != content) {
+				IPane pane = bottomPane.Content as IPane;
+				if (pane != null)
+					pane.Closed();
+				bottomPane.Content = content;
+			}
 			bottomPane.Visibility = Visibility.Visible;
 		}