Problem : "Element is already the child of another element."
Building modular apps with Silverlight 4 and MEF was pretty easy for my first attempt, using the Silverlight Application template. But when I tried to take the same approach and apply it to a silverlight navigation template I get this error: "Element is already the child of another element.". This error is caused by navigating to another page and then back to the previous page.
(Ex: say you on home.xaml and navigate to about.xaml and then back to home.xaml, the error mention above will be thrown.)
How to resolved error
To reproduce, simply override the OnNavigatedFrom event and do any clean up is necessary.
Ex:
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
//clear items that you may have imported from MEF
//TopLeftRegion.Items.Clear();
}
Enjoy!