I have a RadSplitContainer docking in an application and when I do the following it either returns DockedLeft or DockedBottom, however I can see that's not correct:
var docking = RadDocking.GetDockState(container)
If I ask for the width and height, I get fixed numbers, not the actual size of the container:
var width = container.ActualWidth; var height = container.ActualHeight;
1 Answer, 1 is accepted
Hello Pete,
Regarding the first question, a possible reason for this discrepancy is that when the split container is dragged, a new container is created for the element, and then it is added to a ToolWindow. The values you receive are from the original container, which stays hidden. What I would suggest is, to handle the SplitContainerCreated event and use the newly created container, instead of the original one.
Regarding the second question, when I set the telerik:RadDocking.SerializationTag attached property to a pane, it gets saved in the XML file as expected. You could test the attached project that has an implemented logic for saving and loading the layout. This is done via button click events and they save and load the docking's children's positions.
Please let me know if this project behaves as expected or whether I'm missing something of importance. I will be awaiting your reply.
Regards,
Stenly
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi, I tried your sample and got the following error:
1>D:\Projects\DockingSaveAndLoadSampleProject\MainWindow.xaml(11,10): error MC3074: The tag 'RadDocking' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'. Line 11 Position 10.
I have a sample from a previous question so I modified that - your solution to use SplitContainerCreated suffers from the same issues - it's stuck on DockedLeft and the same size even if I adjust the window width/height or location.
In this sample, the serialization works whereas in my main application it doesn't - I haven't figured out what the major differences are yet.
This error is usually present when the wrong assemblies have been referred. The Target framework for the provided project in my last reply is .NET Framework 4.7.2, so, in order for it to work correctly, the assemblies from the WPF45 folder are needed.
Regarding the SplitContainerCreated event, the provided project that implements it works correctly on my end after docking the container to a new location. The width and the height of the created split container are reported correctly every time they are changed. Regarding the docking state, it will only update its value when it is docked in another place. The output that it prints, when the container is dragged and docked, is as follows:
Regarding the serialization issue, could you provide a bit more information regarding how the saving and loading is done?
I got your sample working by adding assemblies that were missing to the project.
I'm getting issues if I try to use SplitContainerCreated and found the docking and sizes are always identical as with my sample project.
So I had a look at SerializationTag. If every item is tagged, it works. If I remove the tag and set it with RadDocking.SetSerializationTag (which is what we use to get unique Ids), then it breaks and the layout isn't saved. I'm attaching your updated project to this reply.
I have tested the provided project, and I noticed that in the OnLayoutChangeEnded event you are using one of the panes, instead of the created split container. This will result in the fixed docking position and sizes that are observed on your end. That said, when a pane is dragged in a floating state, a new pane is rendered, while the original one is still present in the docking, but it stays hidden. That said, could you specify, which sizes are needed?
Regarding the serialization tag part of the question, the layout is saved correctly in the XML file. There weren't any issues with the layout's saving and loading when the project was tested. I have also tried removing the tags from the XAML file and setting them in the SaveLayout method, which did not result in any saving issues. Could you try updating to the latest version to see if this behavior is still present? Also, if you could provide a video showing this, as well as the resulting XML file.
Oops, I changed OnLayoutChangeEnded:
private void OnLayoutChangeEnded(object sender, EventArgs e) { Trace.WriteLine("OutputPane"); Trace.WriteLine($"Docking: {RadDocking.GetDockState(OutputPane)}"); Trace.WriteLine($"Width: {OutputPane.ActualWidth}"); Trace.WriteLine($"Height: {OutputPane.ActualHeight}"); if (m_splitContainer != null) { Trace.WriteLine("Split Container"); Trace.WriteLine($"Docking: {RadDocking.GetDockState(m_splitContainer)}"); Trace.WriteLine($"Width: {m_splitContainer.ActualWidth}"); Trace.WriteLine($"Height: {m_splitContainer.ActualHeight}"); } }
The values of the split container matched the Pane and were incorrect - I tried docking to the right - the split container indicated it was docked to the left.
Here's the layout.xml generated on Save Layout:
<?xml version="1.0" encoding="utf-8"?>
<RadDocking SerializationTag="DockingTag">
<SplitContainers>
<RadSplitContainer SerializationTag="Container" Dock="DockedTop" Height="180">
<Items>
<RadPaneGroup SerializationTag="Group12345" SelectedIndex="0">
<Items>
<RadPane SerializationTag="H2323" IsDockable="True" Header="Error List"/>
</Items>
</RadPaneGroup>
<RadPaneGroup RelativeWidth="100" RelativeHeight="100" IsAutoGenerated="True" SelectedIndex="0">
<Items>
<RadPane SerializationTag="12345" IsDockable="True" Header="Output"/>
</Items>
</RadPaneGroup>
</Items>
</RadSplitContainer>
</SplitContainers>
</RadDocking>
We are using SerializationTag and I can see the container is being saved, but not the individual panes inside the container. I've tried adding
and similar to the items but other than the top level container, nothing gets written to the XML file. The component looks like the following:
<telerik:RadSplitContainer telerik:RadDocking.SerializationTag="FormPaneContainer"> <telerik:RadPaneGroup telerik:RadDocking.SerializationTag="RadPaneGroup"> <telerik:RadPane Header="Form" telerik:RadDocking.SerializationTag="RadPaneForm"> ... </telerik:RadPane> </telerik:RadPaneGroup> </<telerik:RadSplitContainer>