0

So I've got a DockingManager described in xaml like this:

<ad:DockingManager
  x:Name="DockingManager"
  Margin="5"
  DocumentHeaderTemplate="{DynamicResource DocumentHeaderTemplate}"
  DocumentPaneControlStyle="{DynamicResource DocumentPaneControlStyle}"
  DocumentsSource="{Binding TabControlItems, Source={StaticResource Locator}}"
  LayoutItemContainerStyle="{DynamicResource LayoutItemContainerStyle}" />

and I'm trying to load my layout like

var dockingManager = mw?.DockingManager;
        if (dockingManager == null)
        {
            return null;
        }

        if (!File.Exists(@"Settings\TabLayout.config"))
        {
            File.Create(@"Settings\TabLayout.config");
        }

        var serializer = new XmlLayoutSerializer(dockingManager);
        serializer.LayoutSerializationCallback += (s, args) => { };
        serializer.Deserialize(@"Settings\TabLayout.config");

But instead of loading how I expect it always loads additional tabs. Ie. If I save 3 tabs, and then load the layout I'll get 6 tabs, 3 empty ones with the layout I saved, and 3 default layout ones with the proper controls.

Does anybody know whats happening? I can't find a thing about it anywhere.

Scott Maher
  • 35
  • 2
  • 5

1 Answers1

0

To any that were wondering,

The issue was that my layout was being loaded before the DocumentsSource was populated, so it added empty tabs to make it work. I tried setting my layout deserialize on WindowLoad, but even that ended up being too soon, so I've got this timer:

mainWindow.Loaded += (sender, args) =>
        {
            // I couldn't find a proper place to put this. 
            // I need an event after 100% of all setup is completed
            var timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(3)
            };

            timer.Tick += (s, e) =>
            {
                DockingManagerDeserialize(mainWindow);
                timer.Stop();
            };

            timer.Start();
        };

And now it works, it's not ideal but its a start.

Scott Maher
  • 35
  • 2
  • 5