Unplanned
Last Updated: 07 Dec 2021 01:31 by Marco
Licensing
Created on: 26 Feb 2014 07:23
Category: Docking
Type: Feature Request
16
Docking: ToolWindow: Add Minimize\Restore\Maximize header buttons
Currently Minimize\Restore\Maximize buttons are not shown in the ToolWindow's header, so there are some inconveniences in use. For example, it's impossible to minimize tool windows easily.
1 comment
Marco
Posted on: 07 Dec 2021 01:31

As a temporary hack i created a custom GeneratedItemsFactory for the RadDocking as descriped in this post: https://www.telerik.com/forums/maximize-mimimize-floating-radpane . Than i create a custom ToolWindow and override the OnContextMenuOpening event and set my own menu with the new options Maximize and Minimize. Hacky, but works. And after 8 years my expectations for this feature are low ;)

public class ShownInTaskBarWindowsGeneratedItemsFactory : DefaultGeneratedItemsFactory
    {
        public override ToolWindow CreateToolWindow()
        {
            // var window = base.CreateToolWindow();
            
            var window = new MyToolWindow();
            window.SetResourceReference(Control.StyleProperty, "ToolWindowStyle");

            RadWindowInteropHelper.SetShowInTaskbar(window, true);
            window.SetBinding(RadWindowInteropHelper.TitleProperty, new Binding("Header") { Source = window });

            return window;
        }
    }

    public class MyToolWindow : ToolWindow
    {
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            var win = e.Source as ToolWindow;

            RadContextMenu menu = new RadContextMenu();

            var minimizeMenuItem = new RadMenuItem { Header = "Minimize", StaysOpenOnClick = false };
            minimizeMenuItem.Click += (sender, args) => win.WindowState = WindowState.Minimized;
            menu.Items.Add(minimizeMenuItem);
            var maximizeMenuItem = new RadMenuItem { Header = "Maximize", StaysOpenOnClick = false };
            maximizeMenuItem.Click += (sender, args) => win.WindowState = WindowState.Maximized;
            menu.Items.Add(maximizeMenuItem);

            RadContextMenu.SetContextMenu((FrameworkElement)e.OriginalSource, menu);
            menu.IsOpen = true;
        }

        protected override System.Windows.Controls.ContentControl GetWindowOwner()
        {
            return null;
        }
    }