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

How to keep the size of a floating pane equal to the size of the pane being docked?

5 Answers 140 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Pieter
Top achievements
Rank 2
Pieter asked on 26 Oct 2011, 09:17 AM
I have panes that are docked, and for example have a size of 640 * 480 while docked. When I move the pane outside the application the floating pane now gets a different size, 220 * 300.

I want to keep the size equal, the floating pane should keep the size of the docked pane. I tried setting RadDocking.SetFloatingSize on the splitcontainer, but that does not help.

How can I solve this?

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 26 Oct 2011, 11:39 AM
Hi Pieter,

I would suggest to subscribe to PaneStateChange event of the RadDocking control and in its handler find the ToolWindow where the pane is placed and set its size like this:

private void dock_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;         
    if (pane != null && pane.IsFloating)
    {
        var window = pane.GetParentToolWindow();
        this.Dispatcher.BeginInvoke(() =>
            {
                if (window != null)
                {
                    window.Width = 100;
                    window.Height = 100;
                }
            });    
    }
}

Hope this helps.

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pieter
Top achievements
Rank 2
answered on 26 Oct 2011, 02:09 PM
Yana,

Thanks for responding. I tried your code, but the floating pane size just does not change.
I changed the code a bit because the lamba did not compile.
Any other suggestions are welcome, also on the subject of retrieving the size of the docked pane before it gets floating.

private delegate void SetToolWindowSizeDelegate(ToolWindow window, double Width, double Height);
        private void SetToolWindowSize(ToolWindow window, double Width, double Height)
        {
            if (!window.CheckAccess())
            {
                window.Dispatcher.BeginInvoke(new SetToolWindowSizeDelegate(SetToolWindowSize), new object[] { window, Width, Height });
            }
            else
            {
                window.Width = Width;
                window.Height = Height;
            }
 
        } // SetWindowSize
 
 
        private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            var pane = e.OriginalSource as RadPane;
            if (pane != null && pane.IsFloating)
            {
                ToolWindow window = pane.GetParentToolWindow();
                SetToolWindowSize(window, 400.0, 500.0);
            }
 
        } // RadDocking_PaneStateChange

0
Yana
Telerik team
answered on 27 Oct 2011, 08:50 AM
Hello Pieter,

I'm sorry for my confusion, this code was for Silverlight.
I've attached a simple WPF project demonstrating the needed approach.

Please download it and give it a try.

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
HoriaTu
Top achievements
Rank 2
answered on 17 Jul 2013, 09:24 PM
The example is great,

But I want to initialize ToolWindow size only when I float the RadPane from its docked (in a RADGroup) position; when I LoadLayout, I need to let the ToolWindow size unchanged (as it was saved with SaveLayout.)

As a minimum code I have:

            saveLayoutControl.LoadingLayout = true;
            try
            {
                using (var isoStream = saveLayoutControl.Model.GetStreemForLoadingLayout(tag))
                {
                    if (isoStream != null)
                    {
                        this.dock.LoadLayout(isoStream);
                    }
                }
            }
            finally
            {
                saveLayoutControl.LoadingLayout = false;
            }

However, in Dock_OnPaneStateChange (from your attached project):
        ...
                this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var tag = pane.Tag as string;
                        if (tag != null)
                        {
                            if (saveLayoutControl.LoadingLayout)
        ...
LoadingLayout is false all the times, whatever initiated from the above code (with LoadLayout) or from undocking the RadDock control!
Looks like LoadLayout works asynchronously and I cannot know when the entire process ends!!!


0
Yana
Telerik team
answered on 23 Jul 2013, 07:57 AM
Hi Horia,

I would suggest that you subscribe to LayoutChangeEnded event of the Docking control and set the LoadingLayout property to false in it as this event fires after PaneStateChange event. Note that as in your current code LoadingLayout should be set to true before LoadLayout method is called.

I hope this helps.

Regards,
Yana
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Docking
Asked by
Pieter
Top achievements
Rank 2
Answers by
Yana
Telerik team
Pieter
Top achievements
Rank 2
HoriaTu
Top achievements
Rank 2
Share this question
or