How to turn off resizing of floating window?

3 posts, 1 answers
  1. Tore
    Tore avatar
    9 posts
    Member since:
    Dec 2012

    Posted 19 Aug Link to this post

    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. Answer
    Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 22 Aug Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tore
    Tore avatar
    9 posts
    Member since:
    Dec 2012

    Posted 22 Aug in reply to Nasko Link to this post

    Hello, just tested out the code suggested. This works like a charm. Thanks!
Back to Top