Is it possible to hide a floating document window?

2 posts, 0 answers
  1. Nicholas
    Nicholas avatar
    12 posts
    Member since:
    Nov 2017

    Posted 08 Mar 2018 Link to this post

    How can I hide a floating document window? Right now it seems as though if you right-click, it gives you the option to be able to hide the window, but when you click on it, it doesn't really hide it, it closes it instead. When I switch the closeAction propery to hide, it seems like you can hide the window now. But when it's on the default behavior for closeaction which is closeanddispose, it just closes it. Is that what it's supposed to do? Is there a way to close the window when I hit the x and if I hide it, it actually hides it? I noticed that if I disable the option to hide (which AutoHide is already disabled), it disables the x in the corner of the window too. 
  2. Hristo
    Hristo avatar
    1522 posts

    Posted 09 Mar 2018 Link to this post

    Hi Nicholas,

    Thank you for writing.

    Whether a window will be hidden or closed is determined by its CloseAction property and the default value is CloseAndDispose. When hiding a floating window with CloseAction different than Hide it will close. This behavior is by design and it is desired. Additional information how the property works is available here:

    As I understand, you would like to have the floating hide when you choose Hide from the context menu and close when clicking the Close button. This can be accomplished by handling the ContextMenuItemClicked event of the context menu service and setting the CloseAction property of the window to Hide. When you show it, however, you will also need to restore the default value of the property so that you can close the window and not hide it when clicking the Close button. Please check my code snippet below: 
    public partial class Form1 : Form
        public Form1()
            ContextMenuService svc = this.radDock1.GetService<ContextMenuService>();
            svc.ContextMenuItemClicked += Svc_ContextMenuItemClicked;
        private void Svc_ContextMenuItemClicked(object sender, ContextMenuItemClickEventArgs e)
            DockWindow window = e.Item.Tag as DockWindow;
            if (window != null && window.DockState == DockState.Floating)
                window.CloseAction = DockWindowCloseAction.Hide;
        private void button1_Click(object sender, EventArgs e)
            DockWindow[] hiddenWindows = this.radDock1.DockWindows.GetWindows(DockState.Hidden);
            foreach (DockWindow dw in hiddenWindows)
                dw.CloseAction = DockWindowCloseAction.CloseAndDispose;

    I am also attaching a short video showing the result on my end.

    I hope this information was useful. Let me know if you have other questions.

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top