Force RadDock to float panes in ordinary windows instead of ToolWindows

6 posts, 0 answers
  1. YBOT
    YBOT avatar
    10 posts
    Member since:
    Jul 2017

    Posted 10 Jun 2019 Link to this post

    Is there a way to enable WPF RadDock to open floated windows in a standalone window rather than a ToolWindow? The feature looks like its available in the WinForms version of RadDock but not WPF RadDock.

    Would this be achieved in the DockingPanesFactory?

     

    <telerik:RadDocking Grid.Row="2" x:Name="radDocking"<br>                            prism:RegionManager.RegionName="DocumentsRegion"<br>                            BorderThickness="0"<br>                            CustomElementLoading="RadDocking_CustomElementLoading"<br>                            HasDocumentHost="False"><br>            <br>            <telerik:RadDocking.DockingPanesFactory><br>                <local1:ShellDockingPanesFactory /><br>            </telerik:RadDocking.DockingPanesFactory><br><br>            <telerik:RadSplitContainer Orientation="Vertical" InitialPosition="DockedLeft"><br>                <telerik:RadPaneGroup HorizontalAlignment="Left"  x:Name="leftGroup" telerik:RadDocking.SerializationTag="leftGroup"/><br>            </telerik:RadSplitContainer><br>            <telerik:RadSplitContainer InitialPosition="DockedRight" ><br>                <telerik:RadPaneGroup HorizontalAlignment="Right" x:Name="rightGroup" telerik:RadDocking.SerializationTag="rightGroup"/><br>            </telerik:RadSplitContainer><br>            <telerik:RadSplitContainer InitialPosition="DockedBottom" ><br>                <telerik:RadPaneGroup x:Name="bottomGroup" telerik:RadDocking.SerializationTag="bottomGroup"/><br>            </telerik:RadSplitContainer><br>            <telerik:RadSplitContainer InitialPosition="FloatingOnly" ><br>                <telerik:RadPaneGroup x:Name="floatingOnlyGroup" telerik:RadDocking.SerializationTag="floatingOnlyGroup"/>   <br>            </telerik:RadSplitContainer><br>            <telerik:RadSplitContainer InitialPosition="FloatingDockable" ><br>                <telerik:RadPaneGroup x:Name="floatingDockableGroup" telerik:RadDocking.SerializationTag="floatingDockableGroup"/><br>            </telerik:RadSplitContainer><br>         <br>        </telerik:RadDocking>

     

    <p>public class ShellDockingPanesFactory : DockingPanesFactory<br>    {<br>        <br>        protected override void AddPane(RadDocking radDocking, RadPane pane)<br>        {<br>           <br>            var paneModel = pane as IPaneModel;<br>            if (paneModel != null && !(pane is RadDocumentPane))<br>            {<br>                RadPaneGroup group = null;<br>                switch (paneModel.Position)<br>                {<br>                    case DockState.DockedRight:<br>                        group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "rightGroup") as RadPaneGroup;<br>                        if (group != null)<br>                        {<br>                            group.Items.Add(pane);<br>                        }<br>                        return;<br>                    case DockState.DockedBottom:<br>                        group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "bottomGroup") as RadPaneGroup;<br>                        if (group != null)<br>                        {<br>                            group.Items.Add(pane);<br>                        }<br>                        return;<br>                    case DockState.DockedLeft:<br>                        group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "leftGroup") as RadPaneGroup;<br>                        if (group != null)<br>                        {<br>                            group.Items.Add(pane);<br>                        }<br>                        return;<br>                    case DockState.FloatingOnly:<br>                        var foSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();<br>                        group = radDocking.GeneratedItemsFactory.CreatePaneGroup();<br>                        foSplitContainer.Items.Add(group);<br>                        group.Items.Add(pane);<br>                        radDocking.Items.Add(foSplitContainer);<br>                        pane.MakeFloatingOnly();<br>                        return;<br>                    case DockState.FloatingDockable:<br>                        var fdSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();<br>                        group = radDocking.GeneratedItemsFactory.CreatePaneGroup();<br>                        fdSplitContainer.Items.Add(group);<br>                        group.Items.Add(pane);<br>                        radDocking.Items.Add(fdSplitContainer);<br>                        pane.MakeFloatingDockable();<br>                        return;<br>                    case DockState.DockedTop:<br>                    default:<br>                        return;<br>                }<br>            }<br>           base.AddPane(radDocking, pane);<br>        }<br>    }</p><p></p>

     

  2. YBOT
    YBOT avatar
    10 posts
    Member since:
    Jul 2017

    Posted 11 Jun 2019 in reply to YBOT Link to this post

    Edit: Better code formatting

    <telerik:RadDocking Grid.Row="2" x:Name="radDocking"
                                prism:RegionManager.RegionName="DocumentsRegion"
                                BorderThickness="0"
                                CustomElementLoading="RadDocking_CustomElementLoading"
                                HasDocumentHost="False">
                 
                <telerik:RadDocking.DockingPanesFactory>
                    <local1:ShellDockingPanesFactory />
                </telerik:RadDocking.DockingPanesFactory>
     
                <telerik:RadSplitContainer Orientation="Vertical" InitialPosition="DockedLeft">
                    <telerik:RadPaneGroup HorizontalAlignment="Left"  x:Name="leftGroup" telerik:RadDocking.SerializationTag="leftGroup"/>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedRight" >
                    <telerik:RadPaneGroup HorizontalAlignment="Right" x:Name="rightGroup" telerik:RadDocking.SerializationTag="rightGroup"/>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedBottom" >
                    <telerik:RadPaneGroup x:Name="bottomGroup" telerik:RadDocking.SerializationTag="bottomGroup"/>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="FloatingOnly" >
                    <telerik:RadPaneGroup x:Name="floatingOnlyGroup" telerik:RadDocking.SerializationTag="floatingOnlyGroup"/>  
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="FloatingDockable" >
                    <telerik:RadPaneGroup x:Name="floatingDockableGroup" telerik:RadDocking.SerializationTag="floatingDockableGroup"/>
                </telerik:RadSplitContainer>
            </telerik:RadDocking>

     

    public class ShellDockingPanesFactory : DockingPanesFactory
        {
            // This is run when a view is Registered to "DocumentsRegion"
            protected override void AddPane(RadDocking radDocking, RadPane pane)
            {
                
                var paneModel = pane as IPaneModel;
                if (paneModel != null && !(pane is RadDocumentPane))
                {
                    RadPaneGroup group = null;
                    switch (paneModel.Position)
                    {
                        case DockState.DockedRight:
                            group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "rightGroup") as RadPaneGroup;
                            if (group != null)
                            {
                                group.Items.Add(pane);
                            }
                            return;
                        case DockState.DockedBottom:
                            group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "bottomGroup") as RadPaneGroup;
                            if (group != null)
                            {
                                group.Items.Add(pane);
                            }
                            return;
                        case DockState.DockedLeft:
                            group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "leftGroup") as RadPaneGroup;
                            if (group != null)
                            {
                                group.Items.Add(pane);
                            }
                            return;
                        case DockState.FloatingOnly:
                            var foSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();
                            group = radDocking.GeneratedItemsFactory.CreatePaneGroup();
                            foSplitContainer.Items.Add(group);
                            group.Items.Add(pane);
                            radDocking.Items.Add(foSplitContainer);
                            pane.MakeFloatingOnly();
                            return;
                        case DockState.FloatingDockable:
                            var fdSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();
                            group = radDocking.GeneratedItemsFactory.CreatePaneGroup();
                            fdSplitContainer.Items.Add(group);
                            group.Items.Add(pane);
                            radDocking.Items.Add(fdSplitContainer);
                            pane.MakeFloatingDockable();
                            return;
                        case DockState.DockedTop:
                        default:
                            return;
                    }
                }
               base.AddPane(radDocking, pane);
            }
  3. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1073 posts

    Posted 12 Jun 2019 Link to this post

    Hello,

    Thank you for the provided snippets.

    Replacing the ToolWindow with a standard MS Window is not possible in the RadDocking control as it is widely used in its internal logic - only descendants of the ToolWindow class are allowed. Based on my understanding, the same is true for the WinForms RadDock - you can only replace the window with a control which inherits from FloatingWindow.

    You can have a look at the "Floating Panes taskbar icons" demo from our SDK Samples Browser for an example of how to customize the floated windows in the WPF RadDocking control. I've also attached the project to my reply for your convenience. Here's the code of interest:

    public class CustomDefaultGeneratedItemsFactory : DefaultGeneratedItemsFactory
    {
        public override ToolWindow CreateToolWindow()
        {
            var window = new MyToolWindow();
            RadWindowInteropHelper.SetShowInTaskbar(window, true);
            RadWindowInteropHelper.SetIcon(window, new BitmapImage(new Uri("pack://application:,,,/FloatingPaneTaskbarIcons;component/Images/icon-default.png", UriKind.Absolute)));
     
            return window;
        }
    }
     
    public class MyToolWindow : ToolWindow
    {
        // custom logic
    }

    Would defining a custom ToolWindow work for your particular scenario? If this is not the case, could you please share some more details on your specific requirement so that I can try to suggest an alternative approach?

    I will be looking forward to your reply.

    Regards,
    Dilyan Traykov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. YBOT
    YBOT avatar
    10 posts
    Member since:
    Jul 2017

    Posted 12 Jun 2019 in reply to Dilyan Traykov Link to this post

    Your attached demo is close to what I need. Are you able to make minimizing independant for the main window and for the tool window(s)? For example if I was to minimize the main window, the tool window will still remain on the screen? Another scenario would be if everything is minimized and I clicked on one of the tool windows in the task bar, only the tool window i've clicked will come into focus. 
  5. YBOT
    YBOT avatar
    10 posts
    Member since:
    Jul 2017

    Posted 14 Jun 2019 in reply to YBOT Link to this post

    I've been able to solve the independent minimizing issue by overriding GetWindowOwner in my custom ToolWindow.

     

    public class MyToolWindow : ToolWindow
    {
        protected override System.Windows.Controls.ContentControl GetWindowOwner()
        {
            return null;
        }
    }
  6. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1073 posts

    Posted 14 Jun 2019 Link to this post

    Hello Toby,

    I'm happy to hear that you were able to achieve the desired result. I can confirm that this is the recommended approach for this scenario.

    Please let me know if I can assist you with anything else.

    Regards,
    Dilyan Traykov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top