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

6 posts, 0 answers
  1. Pieter
    Pieter avatar
    34 posts
    Member since:
    Jan 2011

    Posted 26 Oct 2011 Link to this post

    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?
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 26 Oct 2011 Link to this post

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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Pieter
    Pieter avatar
    34 posts
    Member since:
    Jan 2011

    Posted 26 Oct 2011 Link to this post

    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

  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Oct 2011 Link to this post

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

  6. HoriaTu
    HoriaTu avatar
    2 posts
    Member since:
    Apr 2013

    Posted 17 Jul 2013 Link to this post

    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!!!


  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jul 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready