title: AvalonDock LayoutRoot example with layout reloaded from file doesn't show properties
body: <p>I am assessing AvalonDock for suitability for a new project and have implemented the example shown in the documentation of the LayoutRoot class. I have added methods to save and restore the layout on shutdown and startup. As can be seen in the images below, the layout is being restored properly, but after the layout is reloaded from the file, the PropertyGrid no longer shows the content from the current document. I suspect this has something to do with the content coming from another element in the XAML, but can't figure out how to get it to display properly after the layout is reloaded. I have tried manually calling PropertyGrid.Update() at various times after the layout is reloaded without any success. Can anyone please explain why this is not working as I expect and how to make it work, if possible?</p>
  
  <p><a href="https://i.stack.imgur.com/enLet.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/enLet.png" alt="PropertyGrid showing properties of button in Document 1"></a>
  Image 1: PropertyGrid showing properties of button in Document 1 before saving.</p>
  
  <p><a href="https://i.stack.imgur.com/T8Jcx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T8Jcx.png" alt="PropertyGrid NOT showing properties of button in Document 1"></a>
  Image 2: PropertyGrid NOT showing properties of button in Document 1 after reloading saved layout.</p>
  
  <p>XAML from example:</p>
  
  <pre><code>&lt;xcad:LayoutRoot x:Name="_layoutRoot" &gt;
      &lt;xcad:LayoutPanel Orientation="Horizontal"&gt;
          &lt;xcad:LayoutAnchorablePane DockWidth="200"&gt;
              &lt;xcad:LayoutAnchorable ContentId="properties" Title="Properties" CanHide="False" CanClose="False"
                                  AutoHideWidth="240" &gt;
                  &lt;!--IconSource="Images/property-blue.png"--&gt;
                  &lt;xctk:PropertyGrid NameColumnWidth="110" Name="pg"
                                     SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}" /&gt;
              &lt;/xcad:LayoutAnchorable&gt;
          &lt;/xcad:LayoutAnchorablePane&gt;
  
          &lt;xcad:LayoutDocumentPaneGroup &gt;
              &lt;xcad:LayoutDocumentPane&gt;
                  &lt;xcad:LayoutDocument ContentId="document1" Title="Document 1" IconSource="Images/document.png" &gt;
                      &lt;Button Content="Document 1 Content" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
                  &lt;/xcad:LayoutDocument&gt;
  
                  &lt;xcad:LayoutDocument ContentId="document2" Title="Document 2" IconSource="Images/document.png"&gt;
                      &lt;TextBox Text="Document 2 Content" AcceptsReturn="True"/&gt;
                  &lt;/xcad:LayoutDocument&gt;
              &lt;/xcad:LayoutDocumentPane&gt;
          &lt;/xcad:LayoutDocumentPaneGroup &gt;
  
          &lt;xcad:LayoutAnchorablePaneGroup DockWidth="125"&gt;
              &lt;xcad:LayoutAnchorablePane&gt;
                  &lt;xcad:LayoutAnchorable ContentId="alarms" Title="Alarms"  &gt;
                      &lt;!--IconSource="../Images/alarm-clock-blue.png"--&gt;
                      &lt;ListBox&gt;
                          &lt;s:String&gt;Alarm 1&lt;/s:String&gt;
                          &lt;s:String&gt;Alarm 2&lt;/s:String&gt;
                          &lt;s:String&gt;Alarm 3&lt;/s:String&gt;
                      &lt;/ListBox&gt;
                  &lt;/xcad:LayoutAnchorable&gt;
  
                  &lt;xcad:LayoutAnchorable ContentId="journal" Title="Journal" &gt;
                      &lt;RichTextBox&gt;
                          &lt;FlowDocument&gt;
                              &lt;Paragraph FontSize="14" FontFamily="Segoe"&gt;
                                  This is the content of the Journal Pane.
                                  &lt;LineBreak/&gt;
                                  A
                                  &lt;Bold&gt;RichTextBox&lt;/Bold&gt; has been added here
                              &lt;/Paragraph&gt;
                          &lt;/FlowDocument&gt;
                      &lt;/RichTextBox&gt;
                  &lt;/xcad:LayoutAnchorable&gt;
              &lt;/xcad:LayoutAnchorablePane&gt;
          &lt;/xcad:LayoutAnchorablePaneGroup&gt;
      &lt;/xcad:LayoutPanel&gt;
  
      &lt;xcad:LayoutRoot.LeftSide&gt;
          &lt;xcad:LayoutAnchorSide&gt;
              &lt;xcad:LayoutAnchorGroup&gt;
                  &lt;xcad:LayoutAnchorable Title="Agenda" ContentId="agenda" &gt;
                      &lt;!--IconSource="../Images/address-book-open.png"--&gt;
                      &lt;TextBlock Text="Agenda Content" Margin="10" FontSize="18" FontWeight="Black" TextWrapping="Wrap"/&gt;
                  &lt;/xcad:LayoutAnchorable&gt;
  
                  &lt;xcad:LayoutAnchorable Title="Contacts" ContentId="contacts"  &gt;
                      &lt;!--IconSource="../Images/address-book-pencil.png"--&gt;
                      &lt;TextBlock Text="Contacts Content" Margin="10" FontSize="18" FontWeight="Black" TextWrapping="Wrap"/&gt;
                  &lt;/xcad:LayoutAnchorable&gt;
              &lt;/xcad:LayoutAnchorGroup&gt;
          &lt;/xcad:LayoutAnchorSide&gt;
      &lt;/xcad:LayoutRoot.LeftSide&gt;
  &lt;/xcad:LayoutRoot&gt;
  </code></pre>
  
  <p>Method that reloads the layout:</p>
  
  <pre><code>    private void LoadDockingManagerLayout(DockingManager docManager)
      {
          string layoutFileName = System.IO.Path.Combine(DirAppData, LayoutFileName);
  
          if (System.IO.File.Exists(layoutFileName) == false)
              return;
  
          var layoutSerializer = new XmlLayoutSerializer(docManager);
  
          layoutSerializer.Deserialize(layoutFileName);
      }
  </code></pre>