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:
The RadDocking class has special properties for getting child elements:
now I add a special method for creating child elements upon loading:
a class for generating child elements.
I make a test method for checking:
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?
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>
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>