I am composing new webbrowser elements like the way below
webnew = new WebBrowser();
webnew.Height = 1024;
webnew.Width = 768;
webnew.Name = "webBrowser1";
webnew.Navigated += new NavigatedEventHandler(wbMain_Navigated);
stackPanel1.Children.Add(webnew);
webnew.Navigate("url");
Now when i remove the element at stackPanel1 like the way below does it get destroyed completely ? I want it to be completely destroyed and removed from ram. If not how to completely destroy such dynamically composed element ? Thank you.
stackPanel1.Children.RemoveAt(0);
C# , C# 4.0 , WPF
Yes, eventually when the garbage collector gets to it.
However, since WebBrowser implements IDisposable - you should really call
webnew.Dispose()
before removing it from the stackpanel.