1
Vote

[2.0] Anchorables without ContentId duplicated when saving/loading layout

description

I ran into this issue on my project at work because I simply wasn't assigning anything to ContentId for my anchorables. To reproduce in the MVVMTestApp, make these changes first:
In the MainWindow.xaml under
<avalonDock:DockingManager.LayoutItemContainerStyleSelector>
    <local:PanesStyleSelector>
        <local:PanesStyleSelector.ToolStyle>
            <Style TargetType="{x:Type avalonDock:LayoutAnchorableItem}">
comment out the line:
<Setter Property="ContentId" Value="{Binding Model.ContentId}" />
so it looks like this:
<!--<Setter Property="ContentId" Value="{Binding Model.ContentId}" />-->
Make sure this is the ToolStyle and not the FileStyle.
Rebuild the solution and run.

Steps:
  1. Select Layout -> Save from the menu.
  2. Select Layout -> Load from the menu.
  3. Select Layout -> Save from the menu.
  4. Observe that now another blank FileStats is created in the UI.
  5. Repeat steps 2 - 4 to see that a new additional FileStats is created each Load/Save cycle.
Overall, it is a fairly easy thing to miss to not assign ContentId. In my case, however, my new anchorables were being created as 'Hidden', so I couldn't visibly see them and it made it look like my layout was loading improperly. It was a huge pain and took most of a workday to figure out how to resolve it.

comments