question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DockPanel Suite DockContent all appearing at top left of DockPanel

See original GitHub issue

Using latest Beta 2 NuGet Package VS 2015 on Win 10 x86 Targetted Solution

image

Sometimes when my program starts it fails to place the DockPanel DockContent in the correct places assigned in the configuration file.

The config file looks like this:

<?xml version="1.0" encoding="utf-16"?>
<!--DockPanel configuration file. Author: Weifen Luo, all rights reserved.-->
<!--!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!-->
<DockPanel FormatVersion="1.0" DockLeftPortion="0.25" DockRightPortion="0.25" DockTopPortion="0.25" DockBottomPortion="0.25" ActiveDocumentPane="-1" ActivePane="-1">
  <Contents Count="5">
    <Content ID="0" PersistString="Imogen3.Forms.Dockable.FrmLogging" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="1" PersistString="Imogen3.Forms.Dockable.FrmTimers" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="2" PersistString="Imogen3.Forms.Dockable.FrmImageAssessmentControl" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="3" PersistString="Imogen3.Forms.Dockable.FrmRestrictedBrowser" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="4" PersistString="Imogen3.Forms.Dockable.FrmGroupCandidates" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
  </Contents>
  <Panes Count="3">
    <Pane ID="0" DockState="DockBottom" ActiveContent="0">
      <Contents Count="1">
        <Content ID="0" RefID="0" />
      </Contents>
    </Pane>
    <Pane ID="1" DockState="DockBottom" ActiveContent="1">
      <Contents Count="1">
        <Content ID="0" RefID="1" />
      </Contents>
    </Pane>
    <Pane ID="2" DockState="Document" ActiveContent="2">
      <Contents Count="3">
        <Content ID="0" RefID="2" />
        <Content ID="1" RefID="3" />
        <Content ID="2" RefID="4" />
      </Contents>
    </Pane>
  </Panes>
  <DockWindows>
    <DockWindow ID="0" DockState="Document" ZOrderIndex="1">
      <NestedPanes Count="1">
        <Pane ID="0" RefID="2" PrevPane="-1" Alignment="Right" Proportion="0.5" />
      </NestedPanes>
    </DockWindow>
    <DockWindow ID="1" DockState="DockLeft" ZOrderIndex="2">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="2" DockState="DockRight" ZOrderIndex="3">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="3" DockState="DockTop" ZOrderIndex="4">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="4" DockState="DockBottom" ZOrderIndex="0">
      <NestedPanes Count="2">
        <Pane ID="0" RefID="0" PrevPane="-1" Alignment="Right" Proportion="0.5" />
        <Pane ID="1" RefID="1" PrevPane="0" Alignment="Right" Proportion="0.215625" />
      </NestedPanes>
    </DockWindow>
  </DockWindows>
  <FloatWindows Count="0" />
</DockPanel>

within my code I have these three DockPanel methods which Gets the ContentFromPersistString, Saves and Loads the Configuration file.

private readonly DeserializeDockContent _deserializeDockContent; 

private IDockContent GetContentFromPersistString(string persistString)
        {
            MainLog("GetContentFromPersistString " + persistString);
            if (persistString == typeof(FrmLogging).ToString())
            {
                logToolStripMenuItem.Checked = true;
                _frmLogging.Dock = DockStyle.Fill;
                return _frmLogging;
            }
            else if (persistString == typeof(FrmTimers).ToString())
            {
                timersToolStripMenuItem.Checked = true;
                _frmTimers.Dock = DockStyle.Fill;
                return _frmTimers;
            }
            else if (persistString == typeof(FrmImageAssessmentControl).ToString())
            {
                imageAssessmentToolStripMenuItem.Checked = true;
                _frmIac.Dock = DockStyle.Fill;
                return _frmIac;
            }
            else if (persistString == typeof(FrmRestrictedBrowser).ToString())
            {
                restrictedBrowserToolStripMenuItem.Checked = true;
                _frmRb.Dock = DockStyle.Fill;
                return _frmRb;
            }
            else if (persistString == typeof(FrmGroupCandidates).ToString())
            {
                groupCandidatesToolStripMenuItem.Checked = true;
                _frmGc.Dock = DockStyle.Fill;
                return _frmGc;
            }
            else
            {
                MainLog("Received Window PersistString: " + persistString);
                return null;
            }
        }

        private void LoadDockingWindowsConfiguration()
        {
            MainLog("LoadDockingWindowsConfiguration()");
            // ReSharper disable once AssignNullToNotNullAttribute
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");

            try
            {
                if (File.Exists(configFile))
                    dockPanel1.LoadFromXml(configFile, _deserializeDockContent);
            }
            catch (Exception ex)
            {
                MainLog("Error: LoadDockingWindowsConfiguration " + ex.Message);
            }

        }

        private void SaveDockingWindowConfiguration()
        {
            MainLog("SaveDockingWindowConfiguration()");
            // ReSharper disable once AssignNullToNotNullAttribute
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
            if (_saveLayout)
                dockPanel1.SaveAsXml(configFile);
            else if (File.Exists(configFile))
                File.Delete(configFile);
        }

in the MainForm initializer I have this:

_deserializeDockContent = GetContentFromPersistString; We Load the Docking configuration in the Form Load Event like this:

LoadDockingWindowsConfiguration(); This is a real nuisance, any help in getting the DockContent placed in the correct locations would be appreciated.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RedMsercommented, Jul 19, 2016

@lextm After a lot of testing, I figured out the issue: If the method specified in the DeserializeDockContent parameter of LoadFromXml throws an exception, this exact behavior will occur. While there is a null check using null-coalescing, the code itself is not actually catching any exceptions when executing the specified method and will cancel the DockPanel initialization completely. I can provide a sample project if needed, but replication should be simple with this additional information.


I am running the latest version of the DockPanel Suite (2.10.0.0) and am currently experiencing the same problem: Screenshot. This bug is not only happening when loading DockContent using LoadFromXML, but also when creating any new DockContent and adding it to the DockPanel.

I will try to create a smaller project showcasing the same issue if possible.

0reactions
lextmcommented, Aug 22, 2016

The unhandled exception dialog should occur before such weird layout happens, so I think that is a more obvious indicator of critical problems. Meanwhile, without wrapping as an inner exception, it is much quicker for the debugger to break at the right spot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DockPanel Suite DockContent all appearing at top left of ...
Sometimes when my program starts it fails to place the DockPanel DockContent in the correct places assigned in the configuration file. The ...
Read more >
[Solved]-DockPanel Suite DockContent all appearing at top ...
Coding example for the question DockPanel Suite DockContent all appearing at top left of DockPanel-winforms c#.
Read more >
Docking from code, can't dock as expected
I want to dock two DockContent objects, both left on a DockPanel, one above the other on the same DockPane (like having some...
Read more >
Weifen Luo DockPanelSuite: Tutorial and Cookbook
WeiFen Luo's DockPanelSuite is an open source window docking library for ... all windows can be docked anywhere – on the top, left,...
Read more >
The DockPanel control
The DockPanel makes it easy to dock content in all four directions (top, bottom, left and right). This makes it a great choice...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found