Creating multiple instances of document and tool window vies

Oct 10, 2014 at 3:56 PM
Edited Oct 10, 2014 at 4:07 PM
I am trying to convert the AvalondockTest sample into a working sample with real viewmodels
and real documents and I cannot seem to create more than 1 document or tool window instance. Here is the code that I am using in HelloWorldModule.cs:
    public void Initialize()
      IRegion r = RegionManager.Regions["DockingRegion"];
      r.Add(new DockingMetadata(DocumentView, new DocumentDockStrategy()) { Title = "Document 123" });
            r.Add(new DockingMetadata(DocumentView, new DocumentDockStrategy()) { Title = "Document 1234" });
            r.Add(new DockingMetadata(ToolView, new SideDockStrategy(DockSide.Left, new GridLength(300))) { Title = "Some Tool", AutoHide = true });
      r.Add(new DockingMetadata(AnotherToolView, new NestedDockStrategy(DocumentView, NestedDockPosition.Bottom, new GridLength(70))) { Title = "Another Tool" });
      r.Add(new DockingMetadata(YetAnotherToolView, new NestedDockStrategy(ToolView, NestedDockPosition.Inside)) { Title = "Yet Another Tool" });

      //DocumentTitle = "Document 123";
I always get the PRISM exception

'View already exists in region."

What am I doing wrong?
Can I get past this exception and use multiple document and tool window views?

I have tried different things, such as, adding and importing another property but
I always seem to get this exception. I also get it when using the serialization. Is it
possible to clear the corresponding region (remove all tool windows and documents)
before loading a layout?