You are right, it seems difficult to define your collapsedDocumentPane in XAML, since AvalonDoc reserve a place for it (tab header or something else), completely ignoring Visibility="Collapsed" , so I ended up adding / removing mine in the code. So:
First, remove your "collapsedDocumentPane" from XAML (I comment on it so that it can be used as a link from the following code):
<ad:DockingManager x:Name="dockManager" Grid.Row="1"> <ad:ResizingPanel Name="resizePanel" Orientation="Horizontal"> <ad:DocumentPane Name="visibleDocumentPane" HorizontalAlignment="Stretch" > <ad:DocumentContent Title="A"/> <ad:DocumentContent Title="B"/> </ad:DocumentPane> </ad:ResizingPanel> </ad:DockingManager>
And recreated that xaml in the code behind (in your xaml.cs file):
private DockablePane _collapsedDocumentPane; private DockablePane CollapsedDocumentPane { get { if (_collapsedDocumentPane== null) { _collapsedDocumentPane= new DockablePane(); var a = new DockableContent { Title = "A", DataContext = _youViewModel,
Then a method that adds or removes it:
private void EvaluateCollapsedDocPaneVisibility() {
Note that the lazy property is loaded - built only when necessary. So now all you have to do is call the method above when you need to add or remove. This is just a sample, you can add an argument to the method to tell him what to do, or something else, hope this helps / helps you.
source share