I had the same problem as you. Not wanting to remove the icons from the actual interface, I just disabled them with event handlers
This is how I worked:
To remove Hide and AutoHide commands:
I added the following handler:
CommandManager.AddPreviewExecutedHandler(this, new ExecutedRoutedEventHandler(this.ContentClosing))
Here 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 correct content. For some reason, sometimes AvalonDock closes other content because it has focus (clicking on the cross will not give focus to your content, and thus it will close the current focused content ...) As you can see, I just redefine the events and I close my components manually
Unfortunately, this does not apply to all cases. I also, for some reason (hello buggy AvalonDock) actually caught a click on the close button, because there is an edge. If you remove the last component, you cannot add a new component because AvalonDock will delete the last remaining panel. Moreover, if you close the 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 imho more sense) I had to add a mouse down handler for each content added so that catch this event. Following the trick, I could do a workaround to avoid this error:
Again, this is an incredible lot of work for such small things, but unfortunately this AvalonDock is far from the finished production environment, and I had to configure such things to make it work.
Hope this works for you, too, and save some of the headaches that I already gave this problem!