Completed
Last Updated: 20 Jun 2014 15:00 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 15 Apr 2014 06:49
Category: Dock
Type: Bug Report
1
FIX. RadDock - LoadFromXml cannot load the controls which belong to the RadDock's DocumentWindow
To reproduce:
1.Add a RadDock with a ToolWindow and a DocumentWindow. Add several controls to all windows. Use the following code:


protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    if (System.IO.File.Exists(@"..\..\..\layoutTest.xml"))
        this.radDock1.LoadFromXml(@"..\..\..\layoutTest.xml");
}


protected override void OnClosing(CancelEventArgs e)
{
    this.radDock1.SaveToXml(@"..\..\..\layoutTest.xml");
    base.OnClosing(e);
}


2. Run the application and change the current layout. 
3. Close the form and run the application again. The controls which belong to the RadDock's DocumentWindow disappear from the dialog.

Workaround:
class MyDock : RadDock
{
    protected override void LoadFromXmlCore(System.Xml.XmlReader reader, bool oldXmlFormat)
    {
        //stop the base logic
        //base.LoadFromXmlCore(reader, oldXmlFormat);
 
        if (reader == null)
        {
            return;
        }
 
        this.ActiveWindow = null;
 
        FieldInfo prevActiveWindow = typeof(RadDock).GetField("prevActiveWindow", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
        prevActiveWindow.SetValue(this, null); //this.prevActiveWindow = null;
 
        FieldInfo attachedWindows = typeof(RadDock).GetField("attachedWindows", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        SortedList<string, DockWindow> _attachedWindows = attachedWindows.GetValue(this) as SortedList<string, DockWindow>;
        MethodInfo CleanAutoHideTabs = typeof(RadDock).GetMethod("CleanAutoHideTabs", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
        CleanAutoHideTabs.Invoke(this, new object[] { _attachedWindows.Values, true }); //this.CleanAutoHideTabs(this.attachedWindows.Values, true);
 
        MethodInfo ResetDesiredDockState = typeof(RadDock).GetMethod("ResetDesiredDockState", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
        ResetDesiredDockState.Invoke(this, null); //this.ResetDesiredDockState();
 
        MethodInfo OnLoadingFromXML = this.DocumentManager.GetType().GetMethod("OnLoadingFromXML", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
        OnLoadingFromXML.Invoke(this.DocumentManager, null); //this.DocumentManager.OnLoadingFromXML();
 
        if (oldXmlFormat)
        {
            this.BeginTransactionBlock(false);
 
            MethodInfo LoadFromOldXml = typeof(RadDock).GetMethod("LoadFromOldXml", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
            LoadFromOldXml.Invoke(this, new object[] {reader}); // this.LoadFromOldXml(reader);
 
            this.EndTransactionBlock();
        }
        else
        {
            MethodInfo LoadFromNewXml = typeof(RadDock).GetMethod("LoadFromNewXml", System.Reflection.BindingFlags.NonPublic |  BindingFlags.Instance);
            LoadFromNewXml.Invoke(this, new object[] { reader }); // this.LoadFromNewXml(reader);
        }
 
        this.EnsureInitialized();
        this.OnLoadedFromXml();
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadDock).FullName;
        }
    }
}
2 comments
ADMIN
Stefan
Posted on: 20 Jun 2014 15:00
Hi,

may I please ask you to open a support ticket with the precise case and a reference to this item we can review it and confirm whether it is the same issue?

Thank you in advance for your time and cooperation.
Imported User
Posted on: 19 Jun 2014 14:58
Q2 2014 has not solved this problem (in my case)