[Verison 2.0] Is there a way to make a tab not closeable?

Jun 8, 2012 at 9:57 PM

Some tabs in my application are critical to always have up.  Is there a way to make it so that those tabs cannot be closed?

Jun 9, 2012 at 10:04 PM

Set CanClose to false, Ado

Jun 10, 2012 at 12:50 PM

If you have an anchorable pane you must set even CanHide to false to hide the "X" button on the header, if you set CanClose="false" only the menu item "Close" of the context menu, or dropdown menu is hidden.

Jun 10, 2012 at 9:39 PM

Yes, mach22 was right. I was not clear, LayouDocument can only be closed and you have only one option CanClose (that you should set to false). If you instead have a tool window (called LayoutAnchorable) you should also set CanHide to false.

Regarding the difference between LayoutDocument and LayoutAnchorable:

LayoutDocument is a window that usually contains your document content, it can be floated in a separate window but can't be docked to a border of the parent DockingManager. A LayoutDocument can be closed and in this case any reference to it is removed.

LayoutAnchorable is a pane that usually contains a tool control (just like the Solution Explorer in VS). It can be floated in a seperated window, re-docked to a different position and can also be auto-hidden to a border. A LayoutDocument can be closed (like the LayoutDocument) and in that case too any reference is removed. Also it can be hidden (default option when you click the X button). If a LayoutAnchorable is hidden, a reference to it is maintained inside the Layout.Hidden collection and its previous position is preserved as much as possible. An hidden LayoutAnchorable can be re-shown to its previous position (when available) just calling the LayoutAnchorable.Show method. If you set CanHide to false you prevent user to hide it.

Ado

Jun 11, 2012 at 6:13 PM
Edited Jun 11, 2012 at 6:23 PM

Ado and mach22,

Thank you for the responses.  I really appreciate it.

Sadly, I am still stuck with this.  I tried to set CanClose and it does not recognize the property.

I have this:

 <avalonDock:LayoutAnchorable Title="Panel 1" CanClose="False">
     <Border Background="Cyan" />
 </avalonDock:LayoutAnchorable>

And Visual Studio errors out with:

The property 'CanClose' does not exist in XML namespace 'http://avalondock.codeplex.com'.
The property 'CanClose' was not found in type 'LayoutAnchorable'. 

I also tried this on a LayoutAchorablePaneGroup, LayoutAnchorablePane, LayoutDocumentPaneGroup, LayoutDocumentPane and a LayoutDocument.  All of them say that CanClose is not found. 

CanClose seems to be a dependency property on LayoutItem.  But I can't seem to access it.

Or am I missing something else?

(I am running v 2.0.0911)

 <avalonDock:LayoutAnchorable Title="Panel 1" CanClose="False">
                                    <Border Background="Cyan" />
                                </avalonDock:LayoutAnchorable>
d
Jun 11, 2012 at 7:25 PM

Its correct the properties are on the LayoutAnchorable, can you post the entire code for the page, or can you provide a sample?

Do you have used the TestApp available with the build?

Jun 11, 2012 at 7:46 PM

If you download the latest build and run the AvalonDock.TestApp you'll see an example on how using these properties

Jun 11, 2012 at 8:40 PM
Edited Jun 11, 2012 at 9:06 PM

This was confusing me hard....

It works in the example project and does not work in my project.

After some thinking I concluded that the only real difference is that my project is using the NuGet package of AvalonDock.

So I went to the AvalongDock.TesetApp project and deleted the reference to AvalonDock and AvalonDock.Themes.VS2010.  I then added the NuGet package "AvalonDock" (version "2.0.0911" (Containing the latest changes the last check in comments).

Once I did that, the AvalongDock.TesetApp project started giving me the same errors my project was giving.

Just to be sure I copied the AvalonDock dlls I built with the AvalonDock source code into my project and it all worked fantastically.

Could there have been an issue with the generation of the latest NuGet package? 

(By the way, I love that you use NuGet.  It makes getting updates so much easier!)