RadSplitContainer not reporting docking state or width/height correctly

1 Answer 53 Views
Docking
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Pete asked on 05 Oct 2021, 04:16 PM

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;

Pete
Top achievements
Rank 1
Iron
Iron
Iron
commented on 08 Oct 2021, 08:44 AM

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

telerik:RadDocking.SerializationTag="FormPaneContainer"

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>
    
We also write out the docking state and width and height in response to LayoutChangeEnded on the docking component, which is where I'm seeing the bad values appearing I first mentioned.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 08 Oct 2021, 02:59 PM

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/.

Pete
Top achievements
Rank 1
Iron
Iron
Iron
commented on 11 Oct 2021, 12:06 PM | edited

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.

Stenly
Telerik team
commented on 14 Oct 2021, 11:01 AM

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? 

Pete
Top achievements
Rank 1
Iron
Iron
Iron
commented on 18 Oct 2021, 04:53 PM

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.

Stenly
Telerik team
commented on 21 Oct 2021, 02:18 PM

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.

 

Pete
Top achievements
Rank 1
Iron
Iron
Iron
commented on 22 Oct 2021, 10:43 AM

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>
I'll see if I can try the latest demo versions of Telerik controls - the ones I'm using for this sample are file version 2021.2.511.40
Tags
Docking
Asked by
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or