Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:18:00+00:00 2026-06-09T22:18:00+00:00

I would like to remove them as this is causing me lots of problems.

  • 0

I would like to remove them as this is causing me lots of problems. If there is a way to solve it I will be glad to try it.
First few minutes of using it I have gotten like 3 different exceptions and I can’t figure out how to remove those damn options.

Pinning and unpinning and pinning, throws an InvalidOperationException because the Operation is not valid due to the current state of the object.

Sometimes pinning and unpinning will open a dialog box and ask me for a file, I don’t want that to happen but it is happening and it throws an exception.

I accidentally click the close button and I cannot get the window back.
It is really frustrating. I am sure other avalondock users have come across this.

And as I don’t want to waste too much time, I am going to ask right here.
How did you get around this exceptions or remove those buttons? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:18:01+00:00Added an answer on June 9, 2026 at 10:18 pm

    I had exactly the same problem as yours. Not willing to remove the icons from the actual UI, I just disabled them with event handlers

    Here is how I worked:

    To remove those Hide and AutoHide commands:

    I added the following handler:

    CommandManager.AddPreviewExecutedHandler(this, new ExecutedRoutedEventHandler(this.ContentClosing))
    

    This is what ContentClosing looks like:

    /// <summary>
    /// Handler called when user clicked on one of the three buttons in a DockablePane
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void ContentClosing(object sender, ExecutedRoutedEventArgs e)
    {
        if (e.Command == ApplicationCommands.Close || e.Command == DockablePaneCommands.Close)
        {
            e.Handled = true;
            DockManager source = sender as DockManager;
            if (source.ActiveContent != null)
            {
                source.ActiveContent.Close();
            }
        }
        else if (e.Command == DockablePaneCommands.Hide || e.Command == DockablePaneCommands.ToggleAutoHide)
        {
            e.Handled = true;
    

    }
    }

    This handler was here to actually close the right content. Fore some reason, sometimes AvalonDock will close another content because it has the focus (clicking on the cross won’t give focus to your content, and thus it will close the currently focused content…)
    As you can see, I just override the events and close manually my components

    Unfortunately, this does not cover all the cases. I also had for some reason (hello buggy AvalonDock) to actually catch the click on the close button because there is an edge case: If you remove the last component, you won’t be able to add a new component, because AvalonDock will remove the last remaining panel. Moreover, if you close a DockableContent with many tabs in it, AvalonDock will close all the tabs, so I had to implement something to just close the current tab (which makes more sense imho) I had to add a mouse down handler to each content added to catch this event. With the following trick, I could do a workaround to avoid this bug:

        /// <summary>
        /// Handler called when a DockableContent state changed.
        /// We need it to define a PreviewMouseDownHandler for each DockablePane
        /// possibly created (which are usually created upon docking a floating window
        /// to a new position) in order to handle single DockableContent closing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void NewContent_StateChanged(object sender, RoutedEventArgs e)
        {
            DockableContent source = sender as DockableContent;
            if (source.State == DockableContentState.Docked && source.Parent is DockablePane)
            {
                DockablePane parent = source.Parent as DockablePane;
                parent.PreviewMouseDown -= mouseHandler;
                parent.PreviewMouseDown += mouseHandler;
            }
        }
    
        /// <summary>
        /// Handler called on mouse down on a DockablePane.
        /// It is designed to detect where did the user click, and 
        /// if he clicked on Close, only the current DockableContent will be closed
        /// (unlike the native behavior which requires us to close the entire DockablePane
        /// upon clicking on Close...)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DockablePaneMouseDown(object sender, MouseButtonEventArgs e)
        {
            DockablePane source = sender as DockablePane;
            if (e.OriginalSource is AvalonDock.ImageEx)
            {
                //User clicked on one of the three icons on the top-right corner of the DockablePane
                if ((e.OriginalSource as AvalonDock.ImageEx).Source.ToString().Contains("PinClose"))
                {
                    RemoveFromUI(source.SelectedItem as DockableContent);
                    e.Handled = true;
                }
            }
        }
    
        /// <summary>
        /// Removes a DockableContent from the currently displayed UI
        /// (called when the original DockableItemsSource changed)
        /// </summary>
        /// <param name="content">The content to be removed</param>
        private void RemoveFromUI(DockableContent content)
        {
            if (content == null)
            {
                return;
            }
            DockablePane parent = content.Parent as DockablePane;
            if (this.ActiveContent == parent.SelectedItem)
            {
                this.ActiveContent = null;
            }
            (parent.SelectedItem as DockableContent).Close();
            //// If the current DockablePane is left empty, we ensure to close it
            if (parent.Items.Count == 0)
            {
                //This case is needed if we are trying to remove the last DockablePane from a DockingManager
                //Native behavior will NOT set the Content property if you remove the last DockablePane:
                //it will therefore consider this CLOSED DockablePane as the current ActiveContent,
                //and will try to add new contents in this closed pane, which seems rather disturbing.
                //Here we explicitly set the Content property to null if we are removing the last element,
                //so next time user adds a tab, it will be added as the new Content!
                if (parent == this.Content)
                {
                    this.Content = null;
                }
                parent.Close();
                parent.Visibility = Visibility.Hidden;
            }
        }
    

    Again, this is an incredible big work for such small matters, but unfortunately, this AvalonDock is far from being production-environment ready and I had to tweak such things to make it work.

    Hope it’ll work for you as well and save yourself some headaches I’ve already given to this problem!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to remove all twitter nicknames (@xxx) from a string like this:
I would like to remove urls from a string and replace them with their
I have a vector with repeated elements, and would like to remove them so
I would like to remove all trailing zeros without truncating or rounding the number
I would like to remove all lines from a textfile which contain a certain
I would like to remove the configuration out of my app.js and split it
I would like to remove the queries information from the website. I am using
I would like to remove one div element, but without its children. For example,
I would like to remove from Mac OS-X taskbar (Dock) the XCode's recent project
I would like to remove some warnings for some classes by generating an automatic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.