If I have xaml like this:
<ad:DockingManager x:Name="_dockingManager" RequestDocumentClose="DockingManager_RequestDocumentClose">
<ad:ResizingPanel Orientation="Vertical">
<ad:DocumentPane x:Name="mainTabPanel"/>
</ad:ResizingPanel>
</ad:DockingManager>
and in My cs file I have this:
private ObservableCollection<DocumentContent> documents;
public ObservableCollection<DocumentContent> Documents
{
get { return documents; }
set { documents = value; }
}
public Demo()
{
InitializeComponent();
this.documents = new ObservableCollection<DocumentContent>();
this._dockingManager.DocumentsSource = this.documents;
...
and when I try to clear DocumentsSource to close all Documents like this
this.Documents.Clear();
none of the Documents closes or disappears.
Now, when I try to close Documents one by one like this:
while (this.documents.Count > 0)
{
this.documents.RemoveAt(0);//this is the same as this.documents[0].Close()
}
I get an exception, but in some very specific case. When I make three documentcontents, and then when I right click on the last document and make a New Vertical Tab, then I right click on a second document and make a New Horizontal Tab. and then when I try to
close all the documents in a way that is described above I get an exception. The thing is, when I try to close all the document in such an order that the first documents that are being closed are in MainDocumentPane then I get an exception.
So, to avoid an exception I have to close all documents like this:
public void CloseAllTabItems()
{
////workaround for avalon dock bug, to close all items you must first close those items that do not belong to MainDocumentPane
ObservableCollection<DocumentContentViewItem> documentsToClose = new ObservableCollection<DocumentContentViewItem>();
foreach (DocumentContentViewItem tabItem in this.documents)
{
if (tabItem.Parent is DocumentPane)
{
if ((tabItem.Parent as DocumentPane).IsMainDocumentPane == false)
{
documentsToClose.Add(tabItem);
}
}
}
foreach (DocumentContentViewItem tabItem in documentsToClose)
{
tabItem.Close();
}
while (this.documents.Count > 0)
{
this.documents[0].Close();
}
}
I hope that someone will be able to resolve this bug.
Comments: Old or obsolete issue. Please ask for reopen if needed in version 2.0
<ad:DockingManager x:Name="_dockingManager" RequestDocumentClose="DockingManager_RequestDocumentClose">
<ad:ResizingPanel Orientation="Vertical">
<ad:DocumentPane x:Name="mainTabPanel"/>
</ad:ResizingPanel>
</ad:DockingManager>
and in My cs file I have this:
private ObservableCollection<DocumentContent> documents;
public ObservableCollection<DocumentContent> Documents
{
get { return documents; }
set { documents = value; }
}
public Demo()
{
InitializeComponent();
this.documents = new ObservableCollection<DocumentContent>();
this._dockingManager.DocumentsSource = this.documents;
...
and when I try to clear DocumentsSource to close all Documents like this
this.Documents.Clear();
none of the Documents closes or disappears.
Now, when I try to close Documents one by one like this:
while (this.documents.Count > 0)
{
this.documents.RemoveAt(0);//this is the same as this.documents[0].Close()
}
I get an exception, but in some very specific case. When I make three documentcontents, and then when I right click on the last document and make a New Vertical Tab, then I right click on a second document and make a New Horizontal Tab. and then when I try to
close all the documents in a way that is described above I get an exception. The thing is, when I try to close all the document in such an order that the first documents that are being closed are in MainDocumentPane then I get an exception.
So, to avoid an exception I have to close all documents like this:
public void CloseAllTabItems()
{
////workaround for avalon dock bug, to close all items you must first close those items that do not belong to MainDocumentPane
ObservableCollection<DocumentContentViewItem> documentsToClose = new ObservableCollection<DocumentContentViewItem>();
foreach (DocumentContentViewItem tabItem in this.documents)
{
if (tabItem.Parent is DocumentPane)
{
if ((tabItem.Parent as DocumentPane).IsMainDocumentPane == false)
{
documentsToClose.Add(tabItem);
}
}
}
foreach (DocumentContentViewItem tabItem in documentsToClose)
{
tabItem.Close();
}
while (this.documents.Count > 0)
{
this.documents[0].Close();
}
}
I hope that someone will be able to resolve this bug.
Comments: Old or obsolete issue. Please ask for reopen if needed in version 2.0