[Version 1.3] Databinding to ItemsSource DP of DocumentPane

Aug 18, 2010 at 10:23 AM
Edited Aug 18, 2010 at 11:01 AM

I'm encountering problems when trying to databind to the ItemsSouce property of the document pane.
Minimalistic, example, ready to run:

<Window x:Class="WpfApplication4.MainWindow"
        xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock" Title="MainWindow"
        Height="350" Width="525">
    <AvalonDock:DockingManager x:Name="dockManager">
        <AvalonDock:ResizingPanel Orientation="Horizontal">
            <AvalonDock:DocumentPane ItemsSource="{Binding DocWindows}" Name="DocuPane" />
MainWindow.xaml.cs, code behind:
using System.Collections.ObjectModel;
using System.Windows;
using AvalonDock;

namespace WpfApplication4
    public partial class MainWindow : Window
        private ObservableCollection<DocumentContent> docWindows;

        public MainWindow()
            this.DataContext = this;

            docWindows = new ObservableCollection<DocumentContent>();
            docWindows.Add(new DocumentContent() { Title = "Doc 1", Content= "Content doc 1" });
            docWindows.Add(new DocumentContent() { Title = "Doc 2", Content = "Content doc 2" });

        public ObservableCollection<DocumentContent> DocWindows
            get { return docWindows; }
The documents show up inside the document pane, however, I cannot switch to another document by clicking on the tab of the document. As soon as I try to close a document (via its context menu), I'm running into an InvalidOperationException (inside the InternalClose() method of DocumentContent.cs.
Is the code above correct or did I miss something? Is there any workaround for that?

Thanks in advance

PS: I'm aware of the fact that almost the same issue was addressed some time ago: http://avalondock.codeplex.com/Thread/View.aspx?ThreadId=32087
However, I couldn't get a solution out of this post.
Aug 18, 2010 at 11:56 AM
What happens if you try to bind on AvalonDock:DockingManager DocumentsSource property directly?