This project is read-only.

Programmatically switch or close document tab

Aug 7, 2008 at 9:12 PM
Could someone provide a brief example on how to switch to or close a document tab (one tab within a document pane) programmatically?

Based on user actions, I want to programmatically close one out of several already-opened document tab.  Also, I would like to be able switch to one of the opened tabs progrommatically, as if the user clicked on the tab.

Any help would be greatly appreciated.  Thanks!
Aug 8, 2008 at 3:56 PM
Close a documentcontent means essentially remove it from its container pane Items collection.
This is the way I prefer to close a documentcontent/dockableContent

//Get ref to the parent document pane
DocumentPane contaninerPane = document.ContainerPane as DocumentPane;

//open the document (use SelectedItem to switch between documents)
containerPane.SelectedItem = document;

//close it
ApplicationCommands.Close.Execute(null, containerPane);