Setting ToolWindow size before it's displayed

8 posts, 1 answers
  1. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 06 Feb 2015 Link to this post

    Hello. I'm trying to use RadDocking in my project, but I am having trouble with floating panes. In my scenario, I want to float a docked pane and to set the floating window size to either specific value or fullscreen, depending on pane content. I need to do it from code-behind.
    I've found this solution: http://www.telerik.com/forums/add-maximize-button-to-radpane-header
    And the idea begind it works. But it also creates an unwanted side effect. I can see the window changing size twice: first, when it appers on the screen (at this point it has some initial size, like 200x300), and second time, when I change its size in PaneStateChange event handler. If pane contains some rendering-heavy content this double resizing is especially noticeable. So the question is: is there a way to set initial ToolWindow size, before it is actually displayed (and rendered) for the first time?
  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 06 Feb 2015 Link to this post

    Hi Nikita,

    You could use the FloatingSize attached property of RadDocking in order to achieve the desired size ofthe ToolWindow - it could be set to the exact Pane whose size you'd like to change :
    <telerik:RadPane x:Name="radPane1" Header="Document 1" telerik:RadDocking.FloatingSize="500,500/">

    Please, give it a try and let us know if it works for you.

    We hope this will help you.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 10 Feb 2015 in reply to Nasko Link to this post

    Yep, it works, thanks. However, to maximize floating window using FloatingSize property I have to manually fetch screen resolution first. Is there no way around it? I would prefer to use

    toolWindow.WindowState = WindowState.Maximized

    instead, but I don't see a way to access ToolWindow, before it is displayed.
    Is it possible to manually create a ToolWindow, manually add a Pane to it, and manually add this floating window to docking tree? Instead of calling Pane.MakeFloatingDockable() method, which gives no direct control over ToolWindow.

    Also are those attached properties documented somewhere? They are tricky to find, using IntelliSense.
  5. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 12 Feb 2015 Link to this post

    Hi Nikita,

    I am glad the FloatingSize property worked for you. Now about your questions:
    • You could use the FloatingWindowState attached property in order to maximize the Pane as soon as it becomes floating::

    <telerik:RadPane x:Name="radPane1" Header="Document 2"telerik:RadDocking.FloatingWindowState="Maximized"/>

    • It is possible to create a floating RadPane (ToolWindow) in code behind and docked to the desired position by adding it to one of the existing PaneGroups. However, could you please provide us some more detailed information about the desired, so we could be able to suggest you the best approach to achieve it?
    • Some more detailed information about these attached properties you could find in the article about SplitContainer from our help documentation.

    Hopes this helps.

    Regards,

    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 12 Feb 2015 in reply to Nasko Link to this post

    Thx, I've missed this property as well. It works now. And i don't need access to ToolWindow now.

    The only thing that i don't quite get is how FloatingSize property works, when I undock the pane from UI (by dragging it with a mouse), and not from code-behind. I'm trying to store the last ToolWindow size for each pane, so i can restore its size when pane is undocked again. Here is the code I came up with:
      //this is my pane view model class
     public class Screen
     {
             public RadPane {get; set;}
             public bool IsFloating {get; set;}
             public Size? FloatingSize {get; set;}
     }
     
     
    //this is RadDocking.PaneStateChange event handler
     private void OnPaneStateChanged(object sender, RadRoutedEventArgs e)
      {
          var pane = (RadPane) e.OriginalSource;
          //Screens is the collection I am using as PanesSource
          var vm = Screens.FirstOrDefault(x => x.Pane == pane);
          if (pane.IsFloating)
          {
              if (!vm.IsFloating)
              {
                  vm.IsFloating = true;
                  pane.GetParentToolWindow().SizeChanged += OnWindowSizeChanged;
              }
          }
          else
          {
              if (vm.IsFloating)
              {
                  vm.IsFloating = false;
                  if (vm.State.FloatingSize.HasValue)
                  {
                     //when pane is docked back I am trying to set it's floating size
                     //so the size is restored next time user undocks it
                      RadDocking.SetFloatingSize(vm.Pane, vm.State.FloatingSize.Value);
                  }
              }
          }
      }
     
      private void OnWindowSizeChanged(object sender, SizeChangedEventArgs e)
      {
          foreach (var screen in Screens.Where(x => x.Pane.IsFloating &&  x.Pane.GetParentToolWindow().Equals(e.OriginalSource)))
          {
              screen.FloatingSize = e.NewSize;
          }
      }


    It works well, if the pane was docked to document host. When I undock it - i can see that the size is restored.
    But if it was docked somewhere else, pinned to the side, for exmaple, the FloatingSize seems to be completely ignored.



  7. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 13 Feb 2015 Link to this post

    Oh, there are a few typos in the code, I wrote it in a hurry, but I hopefully you get the idea. I don't see an "edit" button anywhere. :)
  8. Nikita
    Nikita avatar
    13 posts
    Member since:
    Jan 2015

    Posted 13 Feb 2015 Link to this post

    Setting FloatingSize to Pane's parent container fixed the issue:

    public class Screen
     {
             public RadPane Pane {get; set;}
             public bool IsFloating {get; set;}
             public Size? FloatingSize {get; set;}
     }
      
    //this is RadDocking.PaneStateChange event handler
     private void OnPaneStateChanged(object sender, RadRoutedEventArgs e)
      {
          var pane = (RadPane) e.OriginalSource;
          //Screens is the collection I am using as PanesSource
          var vm = Screens.FirstOrDefault(x => x.Pane == pane);
          if (pane.IsFloating)
          {
              if (!vm.IsFloating)
              {
                  vm.IsFloating = true;
                  pane.GetParentToolWindow().SizeChanged += OnWindowSizeChanged;
              }
          }
          else
          {
              if (vm.IsFloating)
              {
                  vm.IsFloating = false;
                  if (vm.FloatingSize.HasValue)
                  {
                     //when pane is docked back I am trying to set it's floating size
                     //so the size is restored next time user undocks it
                    //only works when undocking from document host (from UI) or by using Pane.MakeFloatingDockable()
                      RadDocking.SetFloatingSize(vm.Pane, vm.FloatingSize.Value);
                      if (vm.Pane.PaneGroup != null)
                      {
                            //this property is used when pinned panes are undocked from UI, apparently
                            //FloatingSize of pane itself is ignored.
                           RadDocking.SetFloatingSize(vm.Pane.PaneGroup, vm.FloatingSize.Value);
                      }
                  }
              }
          }
      }
      
      private void OnWindowSizeChanged(object sender, SizeChangedEventArgs e)
      {
          foreach (var screen in Screens.Where(x => x.Pane.IsFloating &&  x.Pane.GetParentToolWindow().Equals(e.OriginalSource)))
          {
              screen.FloatingSize = e.NewSize;
          }
      }
    Is this the right approach? Or is there an easier way to restore floating size?
  9. Answer
    Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 16 Feb 2015 Link to this post

    Hi Nikita,

    We have checked the provided code snippet and it seems that the used approach works fine. However, we could not guarantee you that it will work as expected in all scenarios. We have also have an item logged in our Feedback portal for the desired functionality. You could easily vote for it and track its status on the following link:
    http://feedback.telerik.com/Project/143/Feedback/Details/114235-set-size-to-the-panes-and-retain-this-size-when-docking-undocking

    Please, do not hesitate to contact us if you have any additional questions concerning Telerik controls.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready