I've the Window shell and I've created a new window that is shown as a Dialog. This new window has its own region named "WizardStepsRegion" and I inject some views inside it.
The first time I click the button that shows the Dialog it works as expected, but the second time I get the following exception:
An exception occurred while creating a region with name 'WizardStepsRegion'. The exception was: System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
I don't understand why I get such exception because I'm creating a new RegionManager to add the regions of the Dialog and I get a new fresh instance every time I show the dialog.
Can somebody explain me what's wrong please?
Here's the code
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
<Button Content="_Previous" Margin="0, 0, 10, 0" />
<Button Content="_Next" />
<ContentControl cal:RegionManager.RegionName="WizardStepsRegion" />
//[RegionMemberLifetime(KeepAlive = false)]
public partial class Wizard : Window
public IRegionManager regionManager;
RegionManager regMan = new RegionManager();
public Wizard(IRegionManager rm)
regionManager = rm;
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
foreach (object v in regMan.Regions["WizardStepsRegion"].Views)
Here's the code that create and show the dialog
Wizard wizard = (Wizard)ServiceLocator.Current.GetInstance(typeof(Wizard));