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

How to turn off resizing of floating window?

2 Answers 406 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Tore
Top achievements
Rank 1
Tore asked on 19 Aug 2016, 10:51 AM

Hello, I am trying to restrict a floating window to be resized manually. In addition, I want a user control to fill out the space it needs and have the floating window adjust to its content. Is this possible?

My XAML:

   <telerik:RadDocking x:Name="radDocking" Height="1" Width="1">                 <telerik:RadSplitContainer InitialPosition="FloatingOnly" telerik:RadDocking.FloatingLocation="100,400"                                                                                telerik:RadDocking.FloatingSize="800,500">                     <telerik:RadPaneGroup>                         <telerik:RadPane x:Name="ScheduleControlPane" CanUserPin="False"  Header="Kontroll" Loaded="ScheduleControlPane_Loaded"                                                          IsHidden="{Binding Path=IsChecked, ElementName=ScheduleControlToggleButton, Converter={StaticResource invertedBooleanConverter}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">                             <controlviews:ControlView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding ControlViewModel}"></controlviews:ControlView>                         </telerik:RadPane>                     </telerik:RadPaneGroup>                 </telerik:RadSplitContainer>             </telerik:RadDocking>

2 Answers, 1 is accepted

Sort by
0
Accepted
Nasko
Telerik team
answered on 22 Aug 2016, 08:50 AM
Hello Tore,

What we could suggest you in order to achieve the desired is to handle the PaneStateChanged event of RadDocking. As soon as the Pane becomes floating the event will be triggered. Inside it you could get the ToolWindow (when the Pane becomes floating it is placed inside ToolWindow) and set the ResizeMode property to NoResize - thus resizing should not be allowed manually. As for the size of the ToolWindow you could get the UserControl (FindChildOfType is one possible approach) and set the Width and Height property of the ToolWindow with the size of the user control as demonstrated below:
private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;
 
    if (pane != null && pane.IsFloating)
    {
        var toolWindow = pane.GetParentToolWindow();
 
        if (toolWindow != null)
        {
            toolWindow.ResizeMode = System.Windows.ResizeMode.NoResize;
            //Find the needed UserControl
            var userControl = toolWindow.FindChildByType<CustomUserControl>() as CustomUserControl;
 
            if (userControl != null)
            {
                //Ser the desired Width and Height
                toolWindow.Width = userControl.ActualWidth;
                toolWindow.Height = userControl.ActualHeight;
            }
        }
    }
}

Hope this helps.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tore
Top achievements
Rank 1
answered on 22 Aug 2016, 10:35 AM
Hello, just tested out the code suggested. This works like a charm. Thanks!
Tags
Docking
Asked by
Tore
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Tore
Top achievements
Rank 1
Share this question
or