This is a migrated thread and some comments may be shown as answers.

Unable to dock pane after a LoadLayout

9 Answers 151 Views
Docking
This is a migrated thread and some comments may be shown as answers.
John Schroedl
Top achievements
Rank 2
John Schroedl asked on 21 Sep 2010, 09:43 PM
Hi,

I am attempting to use SaveLayout and when our app is re-run I use LoadLayout.  Unfortunately, if the user floats a pane and then exits the app (saving the layout), and later re-runs the app and I load the layout, the floating pane is no longer able to be docked.

Looking in the XML that's written I see the RadSplitContainer is written with InitialPosition="FloatingOnly" which seems suspicious. I tried manually updating the XML file to set InitialPosition="FloatingDockable" but the pane is still not dockable.

If it matters, I do have SerializationTag set for all my panes, splitters and panegroups and do override the ElementLoaded event to plug in my own children of each pane (that part is working great).

Does anyone know what I can change to make the reconstituted Pane dockable again?

Thanks,
John


9 Answers, 1 is accepted

Sort by
0
John Schroedl
Top achievements
Rank 2
answered on 22 Sep 2010, 09:43 PM
I have more information after a day lost in debugging...

1. When a pane is grabbed by mouse and manually un-docked, it can be re-docked (the desired effect). Later, when I use SaveLayout() , the RadSplitContainer in the floating tool window will write InitialPosition="FloatingOnly" which is blatantly wrong.  This is surely a bug in RadDocking. 

2. I have hacked a work-around which I'll share in hopes that somone has a better way.

First, I load the layout XML into memory using Linq to XML and "fix-up" the InitialPosition attribute value to be "FloatingDockable". I then feed this updated XML to LoadLayout(). This is vulnerable to a future change in the RadDocking XML.

This was not sufficient to fix the problem as the RadPane is also sometimes marked with IsDockable="False" in the XML produced by SaveLayout. I never set this attr in code and have the ContextMenuTemplate = null (so users cannot uncheck 'Dockable') so this appears to be another bug in the docking framework. I repair this for all panes handled in the ElementLoaded event by calling pane.MakeDockable();

I would love to be proven wrong in something I'm doing.

John
0
George
Telerik team
answered on 24 Sep 2010, 02:26 PM
Hi John,

Thank you for contacting us.

We are not aware of such issue with RadDocking. I tried to reproduce your scenario in our online examples, but to no avail. Attached you can find the demo I made for you.  Please let me know if I did something wrong.

Looking forward to your reply.

All the best,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John Schroedl
Top achievements
Rank 2
answered on 24 Sep 2010, 03:12 PM
Thank you for responding George, I'd love to try out your example to compare to my code.

Unfortunately, I don't see an attachment on your message or on the thread.

John
0
John Schroedl
Top achievements
Rank 2
answered on 24 Sep 2010, 04:22 PM
I'm working on my own sample to demonstrate the issue. 

But..it's currently very close to our main app and is working!!  So that's good...but also tricky b/c the difference must be attributable to something small.  ex. the test has a textbox in each pane but our main app has other controls, of course.

Another difference from other samples I've looked at is that in our main app, I need to populate the RadDocking control in code (C++/CLI) and not XAML but my sample is C# so I may be overlooking something small in the differences.  Will keep investigating...

John
0
Accepted
George
Telerik team
answered on 29 Sep 2010, 09:56 AM
Hello John,

Sorry for this misunderstanding. Here is the attachment.

I hope it helps! I will be glad to assist you further.

Best wishes,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John Schroedl
Top achievements
Rank 2
answered on 29 Sep 2010, 01:29 PM
Thanks George,  your example is very similar to the standalone example I also created and they both work.  It's still not working in our main application even though I've carefully compared to make sure the calls are the same.  At this point, it looks like I must live with the bug or try to eliminate more possible external causes by process of elimination. 

Thanks again for your example!

John
0
Kevin
Top achievements
Rank 1
answered on 05 Nov 2010, 06:09 PM
I was able to reproduce a problem loading a saved layout using the project attached to this thread. Since this thread is already marked answered, I made a new thread about it here:

http://www.telerik.com/community/forums/wpf/docking/unable-to-load-layout-after-saving-floating-pane.aspx#1407532
0
Arnstein
Top achievements
Rank 1
answered on 21 Dec 2010, 04:14 PM
I'm having the same issue ('FloatingOnly'), and the link to the new thread is giving me a 'Server Error' so I can't look for a solution there...
0
John Schroedl
Top achievements
Rank 2
answered on 21 Dec 2010, 04:41 PM
bool MainWindow::loadSavedLayout(CLR::String^ filePath)
{
    bool success = false;
  
    try
    {
        if (System::IO::File::Exists(filePath))
        {
            using namespace System::Xml::Linq;
  
            System::IO::Stream^ stream = System::IO::File::Open(filePath, System::IO::FileMode::Open);
            XElement^ root = XElement::Load(stream);
            stream->Close();
  
            Assert(root != nullptr);
  
            // Fixup the layout XML due to RadDocking bug which will prevent
            // any floating panes from being dockable after loading the layout.
  
            XElement^ splitContainers = root->Element("SplitContainers");
            if (splitContainers != nullptr)
            {
                IEnumerable<XElement^>^ containers = splitContainers->Elements("RadSplitContainer");
                for each(XElement^ c in containers)
                {
                    for each (XAttribute^ a in c->Attributes("InitialPosition"))
                    {
                        if (a->Value == "FloatingOnly")
                            a->Value = "FloatingDockable";
                    }
                }
            }
            // DEBUG: root->Save("C:\\temp\\layout.xml");
  
            System::IO::Stream^ memstream = gcnew System::IO::MemoryStream();
            root->Save(memstream);
            memstream->Flush();
            memstream->Seek(0, System::IO::SeekOrigin::Begin);
  
            m_radDocking->LoadLayout(memstream);
            memstream->Close();
  
            success = true;
        }
    }
    catch (System::Exception^)
    {
        DBGMSG("Unable to load layout");
    }
  
    return success;
}

This is the heart of the code I ended up using as a workaround. Sorry it's C++ but it should be easy to convert if you need C#.

John
Tags
Docking
Asked by
John Schroedl
Top achievements
Rank 2
Answers by
John Schroedl
Top achievements
Rank 2
George
Telerik team
Kevin
Top achievements
Rank 1
Arnstein
Top achievements
Rank 1
Share this question
or