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

ToolWindow and LocationChanged

2 Answers 78 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 08 Aug 2011, 12:41 PM
Given a Floating ToolWindow the LocationChanged event doesnt fire when the window is dragged. This is making it impossible to ensure that the windows stay inside the main view as we cannot detect when the position changes to constrain the movement. Any ideas for workarounds?

2 Answers, 1 is accepted

Sort by
0
bg
Top achievements
Rank 1
answered on 09 Aug 2011, 03:21 PM
This broke for me as well in Q2. Here is my workaround.

During the PaneStateChange Event for the rad docking control attache an event handler for LayoutChangeEnded on the tool window:
private void radDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            foreach (RadPane pane in radDocking.Panes)
            {
                if (pane != null && pane.IsFloating)
                {
                    INotifyLayoutChange window = GetToolWindowNLC(pane);
 
                    if (window != null)
                    {
                        window.LayoutChangeEnded += new EventHandler(window_LayoutChangeEnded);
                    }
                }
            }
        }
Here is the code for GetToolWindowNLC:
private INotifyLayoutChange GetToolWindowNLC(RadPane pane)
        {
            ToolWindow window = pane.ParentOfType<ToolWindow>();
 
            if (window == null)
            {
                return (((pane.Parent as RadPaneGroup).Parent as RadSplitContainer).Parent) as INotifyLayoutChange;
            }
 
            return window as INotifyLayoutChange;
        }

This will keep the tool window within the bounds of your application:
void window_LayoutChangeEnded(object sender, EventArgs e)
        {
            ToolWindow window = (ToolWindow)sender;           
 
            if (window.Top < 0)
            {
                window.Top = 1;
            }
 
            if (window.Left < 0)
            {
                window.Left = 1;
            }
 
            if (window.Top > this.radDocking.ActualHeight - window.ActualHeight)
            {
                window.Top = this.radDocking.ActualHeight - window.ActualHeight;
            }
 
            if (window.Left > this.radDocking.ActualWidth - window.ActualWidth)
            {
                window.Left = this.radDocking.ActualWidth - window.ActualWidth;
            }
        }
Hope that helps you out. It worked for me.

0
Ivo
Telerik team
answered on 11 Aug 2011, 12:46 PM
Hello Neil,

Thank you for your feedback.

This issue is now fixed and the fix will be available with the next internal build.

Please do not hesitate to contact us if you require any further information or help.

Kind regards,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package.
Get now >>
Tags
Docking
Asked by
Neil
Top achievements
Rank 1
Answers by
bg
Top achievements
Rank 1
Ivo
Telerik team
Share this question
or