NOTE: This blog entry is specific to the old DockingManager control. If you are interested in using the latest version of the TCEK w/the RadDock, I've posted an updated blog entry here.
Welcome to the fourth tutorial in my series of tutorials about the Telerik CAB Enabling Kit. This week, we will learn how to use the RadDockableWorkspace. I will be using the completed project from tutorial 2 as a base for this project. If you have not completed the second tutorial, I suggest doing so before completing this tutorial. You can find it here. Otherwise, click here to download the source code that we will be using, fire up visual studio, and lets begin.
In this section, we will replace the current workspace with a RadDockableWorkspace. The RadDockableWorkspace works differently than the tradition CAB workspace controls. We will actually be using a DockingManager control in the ShellLayoutView instead of an actual workspace style control. The RadDockableWorkspace will instead be created and added in Module.cs with the DockingManager being passed into it as one of its parameters.
public ShellLayoutView() |
{ |
InitializeComponent(); |
//_mainWorkspace.Name = WorkspaceNames.MainWorkspace; |
} |
public DockingManager MainDockWorkspace |
{ |
get { return _mainDockWorkspace; } |
} |
// Add the RadDockableWorkspace to be used as the primary view |
RadDockableWorkspace dockWorkspace = new RadDockableWorkspace(_shellLayout.MainDockWorkspace, _shellLayout); |
_rootWorkItem.Workspaces.Add(dockWorkspace, WorkspaceNames.MainWorkspace); |
As you probably already know, the SmartPartInfo is the lifeline of views added to a workspace. It is responsible for telling the workspace the properties of the container in which it will be placed. In this case, that container is an IDockable.
In this step, we will add a new view so that we can show the full usage of the RadDockableWorkspace. We will also wire up some buttons on the view to invoke our commands we implemented during the second tutorial.
protected override void OnLoad(EventArgs e) |
{ |
_presenter.OnViewReady(); |
base.OnLoad(e); |
// Add invokers to the toolbox buttons |
_presenter.WorkItem.Commands[CommandNames.AddAsset].AddInvoker(btnAddAsset, "Click"); |
_presenter.WorkItem.Commands[CommandNames.RemoveAsset].AddInvoker(btnRemoveAsset, "Click"); |
_presenter.WorkItem.Commands[CommandNames.EditAsset].AddInvoker(btnEditAsset, "Click"); |
} |
private void AddViews() |
{ |
AssetListing view = ShowViewInWorkspace<AssetListing>(WorkspaceNames.MainWorkspace); |
ToolBoxView toolBoxView = ShowViewInWorkspace<ToolBoxView>(WorkspaceNames.MainWorkspace); |
} |
If you are wondering why I didn’t cover theming for this workspace like I did for the RadTabWorkspace, there is a simple explanation. The RadTabWorkspace actually inherits from a RadTabStrip and therefore loses its default namespace information required by themes. In the case of the RadDockableWorkspace, we are actually using a DockingManager directly in our layout and wrapping it with a RadDockableWorkspace when we add it to the Workspaces collection. This means we can simply drag a theme control from the toolbox to our LayoutView and apply it to the DockingManager directly.
Click here to download the source code used in this post.