private void btnMemoryLeak_Click(object sender, RoutedEventArgs e) { // remove the view ViewContainer.Children.Clear(); // create a new instance of the view var newView = new TestView(); // the following line is the source of the memory leak, when the // view is cleared the previous view cannot be garbage collected DummyEvent += newView.EventHandler; // add the view to the stackpanel ViewContainer.Children.Add(newView); // increment our display counter this.Counter++; UpdateDisplayCounter(); }