我目前面临一个非常奇怪的问题。我在使用Caliburn.Micro的WPF应用程序中使用AvalonDock(嵌入在最后一个WPF Extended Toolkit 3中)。
在我的 MainView.xml 中,我有这个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)]">
在 DockingManagerVM.cs 的构造函数中,我创建了一些要显示的默认文档:
Documents = new ObservableCollection<GenericDocumentViewModel>();
Documents.Add(new MyDocumentViewModel());
Documents.Add(new MyDocumentViewModel());
Documents.Add(new MyDocumentViewModel());
CurrentDocument = _documents[0];
显然我定义了&#34;映射&#34;在MyDocumentViewModel和要在XAML中显示为文档的视图之间:
<xcad:DockingManager.Resources>
<DataTemplate DataType="{x:Type vm:MyDocumentViewModel}" >
<local:MyDocumentView />
</DataTemplate>
</xcad:DockingManager.Resources>
出于某种原因,当我尝试关闭之前未激活的文档时(通过单击相应的选项卡),应用程序崩溃并显示以下消息:
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsBase.dll
Additional information: Object reference not set to an instance of an object.
不幸的是,Visual Studio没有提供任何细节(如果你知道如何获得它们会很棒)。
以下是我尝试重现(或不重现)问题的步骤:
运行应用程序;有3个文件,第一个是活动的并显示,然后:
如果您发现我正在做的事情有什么问题,或者是否有任何方法可以调试AvalonDock以了解发生了什么,请您告诉我吗?
非常感谢!
答案 0 :(得分:2)
最后我找到了解决方案!看起来这是与AvalonDock 3.0.0(随Extended.WPF.Toolkit 3.0.0提供)相关的错误。
我从NuGet经理那里安装了修复问题的Xceed.Wpf.AvalonDock(版本3.2.16567.21060)。
之后,由于我导入了external VS2013 theme,NuGet自动切换到Xceed.Wpf.Avalondock 2.9.15603.14400,它也能正常工作。 :)