null reference exception when calling Open()

Docking/MDI for WPF Forum

Posted 15 years ago by John Dunn
Version: 10.1.0521
Avatar
I'm getting a null reference exception when attempting to open a simple DocumentWindow. I assume it's something I'm missing. The XAML is

<UserControl x:Class="DocumentContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking">
  <docking:DockSite x:Name="_DockSite">
    <docking:TabbedMdiHost
      CanDocumentsDockBottom="False"
      CanDocumentsDockLeft="False"
      CanDocumentsDockRight="False"
      >
      <docking:TabbedMdiContainer x:Name="_TabHost">
      </docking:TabbedMdiContainer>
    </docking:TabbedMdiHost>
  </docking:DockSite>
</UserControl>
and I'm using the following code to create and open my document

      DocumentWindow doc = new DocumentWindow(_DockSite)
      {
        Title = "test",
        Content = new TextBlock() { Text = "this is a test" },
      };
      doc.Open();
The .Open call throws a null reference exception. The InnerException is null.

Comments (1)

Posted 15 years ago by John Dunn
Avatar
Fixed it - I was missing the Workspace from my XAML -

<UserControl x:Class="DocumentContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking">
  <docking:DockSite x:Name="_DockSite">
    <docking:Workspace>
      <docking:TabbedMdiHost>
        <docking:TabbedMdiContainer x:Name="_TabHost">
        </docking:TabbedMdiContainer>
      </docking:TabbedMdiHost>
    </docking:Workspace>
  </docking:DockSite>
</UserControl>
One odd behavior I'm still seeing is that if all my documents are currently 'rafted', I can't drag them back into the TabbedMdiContainer. If I then add a new page directly to the TabbedMdiContainer I can then drag the rafted windows back in. The 'Dock' command on the rafted window does work. Is this by design?
The latest build of this product (v24.1.3) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.