Reputation: 790
I'm currently facing a very odd problem. I'm using AvalonDock (embedded in the last WPF Extended Toolkit 3) on a WPF application with Caliburn.Micro.
In my MainView.xml I have this DockingManager:
<xcad:DockingManager x:Name="dockMngr"
Grid.Row="1"
AllowMixedOrientation="True"
DataContext="{Binding DockingManagerVM}"
DocumentsSource="{Binding Documents}"
AnchorablesSource="{Binding Anchorables}"
ActiveContent="{Binding CurrentDocument, Mode=TwoWay}"
cal:Message.Attach="[Event DocumentClosed] = [Action DocumentClosed($eventArgs)];
[Event DocumentClosing] = [Action DocumentClosing($eventArgs)]">
In the constructor of the DockingManagerVM.cs I create some default documents to be displayed:
Documents = new ObservableCollection<GenericDocumentViewModel>();
Documents.Add(new MyDocumentViewModel());
Documents.Add(new MyDocumentViewModel());
Documents.Add(new MyDocumentViewModel());
CurrentDocument = _documents[0];
Obviously I defined the "mapping" between MyDocumentViewModel and the view to be displayed as a document in the XAML:
<xcad:DockingManager.Resources>
<DataTemplate DataType="{x:Type vm:MyDocumentViewModel}" >
<local:MyDocumentView />
</DataTemplate>
</xcad:DockingManager.Resources>
For some reason when I try to close a document that I didn't made active before (by clicking on the corresponding tab) the application crashes with this message:
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsBase.dll
Additional information: Object reference not set to an instance of an object.
Unfortunately no details are provided from Visual Studio (if you have any idea how to get them it will be great).
The following are steps I tried to reproduce (or not) the issue:
Run the application; there are 3 documents, the first one is active and shown, then:
Could you please tell me if you notice something wrong in what I am doing or if is there any way to debug AvalonDock in order to figure out what is going on?
Thank you very much!
Upvotes: 2
Views: 930
Reputation: 790
Finally I found a solution! It seems like this is a bug related to AvalonDock 3.0.0 (provided with Extended.WPF.Toolkit 3.0.0).
From the NuGet manager I installed Xceed.Wpf.AvalonDock (version 3.2.16567.21060) that fixed the problem.
After that, since I imported an external VS2013 theme, NuGet automatically switched to Xceed.Wpf.Avalondock 2.9.15603.14400, and it works properly as well. :)
Upvotes: 3