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

Save and load layout

3 Answers 230 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Nikolay
Top achievements
Rank 1
Nikolay asked on 27 Dec 2010, 12:21 PM
I make a Docking class set with an overwritten behavior.
I save the layout elements.
I make simple heirs of the elements set for docking:


public class TSplitContainer : RadSplitContainer { }
public class TPaneGroup : RadPaneGroup { }
public class TPane : RadPane { }


The RadDocking class has special properties for getting child elements:

d = new TDocking();
//d.CurrentSaveLoadLayoutHelper = new TDefaultSaveLoadLayoutHelper(d);
d.GeneratedItemsFactory = new TDefaultGeneratedItemsFactory();


now I add a special method for creating child elements upon loading:

public class TDocking: RadDocking
{
   protected override void OnElementLoading(LayoutSerializationLoadingEventArgs args)
   {
System.Windows.DependencyObject res = args.AffectedElement;
if (res == null)
{
string st = args.AffectedElementSerializationTag;
if (st == typeof(TDocking).Name)
args.SetAffectedElement(this);
if (st == typeof(TDocumentPane).Name)
args.SetAffectedElement(new TDocumentPane());
if (st == typeof(TPaneGroup).Name)
args.SetAffectedElement(GeneratedItemsFactory.CreatePaneGroup());
if (st == typeof(TSplitContainer).Name)
args.SetAffectedElement(GeneratedItemsFactory.CreateSplitContainer());
}
System.Diagnostics.Debug.WriteLine("OnElementLoading: serializationTag={0}; res={1}", args.AffectedElementSerializationTag, res);
base.OnElementLoading(args);
   }
}


a class for generating child elements.

  
public class TDefaultGeneratedItemsFactory: DefaultGeneratedItemsFactory
{
public override Telerik.Windows.Controls.RadPaneGroup CreatePaneGroup()
{
return new TPaneGroup();
}
public override Telerik.Windows.Controls.RadSplitContainer CreateSplitContainer()
{
return new TSplitContainer();
}
public override ToolWindow CreateToolWindow()
{
return base.CreateToolWindow();
}
}


I make a test method for checking:

d = new TDocking();
//d.CurrentSaveLoadLayoutHelper = new TDefaultSaveLoadLayoutHelper(d);
d.GeneratedItemsFactory = new TDefaultGeneratedItemsFactory();
 
TSplitContainer sc = new TSplitContainer();
d.Items.Add(sc);
TDocking.SetSerializationTag(sc, "TSplitContainer");
sc.InitialPosition = Telerik.Windows.Controls.Docking.DockState.DockedRight;
 
TPaneGroup pg = new TPaneGroup();
TDocking.SetSerializationTag(pg, "TPaneGroup");
sc.Items.Add(pg);
 
TPane pane = new TPane();
TDocking.SetSerializationTag(pane, "TPane");
pg.Items.Add(pane);
d1.LoadLayout(xml);


and now upon calling the LoadLayout method we get the following exception:
   at Telerik.Windows.Controls.Docking.DockingLayoutFactory.GetElementByTypeName(String elementTypeName)
   at Telerik.Windows.Controls.Docking.DockingLayoutFactory.LoadSplitContainer(XmlReader reader)
   at Telerik.Windows.Controls.Docking.DockingLayoutFactory.LoadDocking(XmlReader reader)
   at Telerik.Windows.Controls.RadDocking.LoadLayout(Stream source, Boolean raiseEventsIfNoSerializationTag)
   at Telerik.Windows.Controls.RadDocking.LoadLayout(Stream source)
   at RadarSoft.Report.Wpf.Viewer.TDocking.LoadLayout(String source) in D:\Report\RadarSoft.Report.WPF.Viewer\Controls\TelerikDubles\TDocking.cs:line 39
   at RadarSoft.Report.QuickApp.MainWindow.btnResult_Click(Object sender, RoutedEventArgs e)

now what do we see in the reflector?

public DependencyObject LoadSplitItem(XmlReader reader)
{
if (reader.Name == "RadSplitContainer")
{
return this.LoadSplitContainer(reader);
}
if (reader.Name == "RadPaneGroup")
{
return this.LoadPaneGroup(reader);
}
return null;
}


So, why go into all this trouble of creating child elements, if they are loaded in the splitter like this:

and how am I to cure this now???

p.s. saved xml file:
<?xml version="1.0" encoding="utf-8"?><TDocking><SplitContainers><TSplitContainer SerializationTag="TSplitContainer" Dock="DockedRight" Width="240"><Items><TPaneGroup SerializationTag="TPaneGroup" SelectedIndex="0"><Items><TPane SerializationTag="TPane" IsDockable="True" /></Items></TPaneGroup></Items></TSplitContainer></SplitContainers></TDocking>

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 03 Jan 2011, 02:20 PM
Hello Nikolay,

We are aware of this issue. We will fix it in one of our future releases. Sorry for any inconvenience caused.

Greetings,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Ryan
Top achievements
Rank 1
answered on 25 Apr 2011, 08:47 PM
I assume this hasn't been fixed yet? I'm suffering from the same issue, wanting to override some methods in RadPaneGroup with a custom class and having the Save/Load layout break because of it.
0
Yana
Telerik team
answered on 26 Apr 2011, 09:41 AM
Hi Ryan,

The issue is still not fixed, we're sorry for the inconvenience.

Regards,
Yana
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
Tags
Docking
Asked by
Nikolay
Top achievements
Rank 1
Answers by
George
Telerik team
Ryan
Top achievements
Rank 1
Yana
Telerik team
Share this question
or