Save/Load Minimized ToolWindows

1 Answer 43 Views
Docking Window
Marco
Top achievements
Rank 1
Iron
Iron
Iron
Marco asked on 06 Mar 2023, 09:28 PM

Hi,

i try to save and load minimized ToolWindows. This works, but the original size gets lost.

Reproduce: Minimize ToolWindow, Save, Load, Restore -> wrong size

I atteched a simple sample where you can push the buttons from 1 to 4 to reproduce it. Pressing button 1 and 4 back and forth works as expected.
In the produced XML i see, that FloatingWidth and FloatingHeight is reset to some "strange" values (160 and 28) after minimize.
When i restore the Window after Load it gets a size of 1440x879

I also dont know how i can sneak in this process to "correct" the values or save some custom/attached ones ...

regards marco

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 09 Mar 2023, 02:08 PM

Hello Marco,

When the layout is saved and then loaded, the ToolWindow will be unloaded and then loaded again, which could cause it to lose values of the normal state. 

What could be done in this scenario is to cache the ActualHeight and ActualWidth properties of the ToolWindow and then reapply them when restoring the state of the window. The chosen approach may vary depending on the structure of your application, however, in the scenario of the sample project that you have provided, these properties could be cached in the Click event handler of the 1st button and then reapplied in the logic of the 4th button.

The following code snippet shows this suggestion's implementation:

private double actualHeight;
private double actualWidth;

//1st button Click event handler
private void MinimizeToolWindow(object sender, RoutedEventArgs e)
{
    var window = this.FlaotingOnlyPane.ParentOfType<ToolWindow>();

	this.actualHeight = window.ActualHeight;
	this.actualWidth = window.ActualWidth;

    window.WindowState = WindowState.Minimized;
}

//4th button Click event handler
private void RestorePaneButtonClick(object sender, RoutedEventArgs e)
{
    var window = this.FlaotingOnlyPane.ParentOfType<ToolWindow>();

	window.WindowState = WindowState.Normal;

	window.Height = this.actualHeight;
	window.Width = this.actualWidth;
}

With this being said, could you give this suggestion a try?

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

Tags
Docking Window
Asked by
Marco
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or