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

Setting ToolWindow size before it's displayed

9 Answers 467 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Nikita
Top achievements
Rank 1
Nikita asked on 06 Feb 2015, 08:40 AM
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?

9 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 06 Feb 2015, 04:08 PM
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.

 
0
Nikita
Top achievements
Rank 1
answered on 10 Feb 2015, 01:36 PM
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.
0
Nasko
Telerik team
answered on 12 Feb 2015, 02:59 PM
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.

 
0
Nikita
Top achievements
Rank 1
answered on 12 Feb 2015, 03:46 PM
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.



0
Nikita
Top achievements
Rank 1
answered on 13 Feb 2015, 06:39 AM
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. :)
0
Nikita
Top achievements
Rank 1
answered on 13 Feb 2015, 06:54 AM
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?
0
Accepted
Nasko
Telerik team
answered on 16 Feb 2015, 09:22 AM
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.

 
0
Manish
Top achievements
Rank 1
answered on 24 Feb 2017, 09:15 AM

Hello,

I have a issue on RadDocking Control, When Minimizing the Mainwindow with ToolWindow does not minimized and this Window Show on Desktop screen.Please help me to find out my Solution

kind regards,

Manish Prajapati

 

0
Nasko
Telerik team
answered on 28 Feb 2017, 07:23 AM
Hi Manish,

The observed by you behavior is not an expected one. The MainWindow of the Application is an Owner of the ToolWindow and because of that when the Window is Minimized the ToolWindow should be Minimized as well. The observed behavior could be caused when the MainWindow is not longer Owner of the ToolWindow.

As we are not exactly sure what is causing that behavior on your side, please provide a sample that reproduces it and send it back to us. We will investigate it further and we will try to provide you with a prompt solution.

Hope the provided information will be helpful for you.

Regards,
Nasko
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Docking
Asked by
Nikita
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Nikita
Top achievements
Rank 1
Manish
Top achievements
Rank 1
Share this question
or