Hello everyone, and welcome to the third tutorial in my series of tutorials about the Telerik CAB Enabling Kit. Over the next two weeks, I will be covering the two workspaces provided with the TCEK. This week, we will learn how to use the RadTabWorkspace. I will be using the completed project from tutorial 2 as the 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 simply replace the current workspace with a RadTabWorkspace. Since the current workspace is already set up within the CAB infrastructure, getting the new workspace set up is as simple as changing the name to be the same as the original workspace.
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 a RadTab.
In this step, we will add a second view to the RadTabWorkspace so that we can showcase the full use of the control.
HelloWorldView helloView = ShowViewInWorkspace<HelloWorldView>(WorkspaceNames.MainWorkspace); |
At this point, the project is now testable. Go ahead and run the application and you should see our two views displayed in tabs in the RadTabWorkspace. What you will notice now is that the TabWorkspace is very bland looking. Next, we will liven it up by applying a theme.
In this step, we will update the RadTabWorkspace control to allow themes. The reason the control currently looks so bland is that theming relies on the namespace of the control. RadTabWorkspace may inherit from RadTabStrip, but since it resides in a different namespace and has a different name than RadTabStrip, theming does not work properly. Fortunately, there is a simple workaround you can use here, and in your own overridden controls, that will solve this problem and allow RadTabStrip themes to be applied.
public override string ThemeClassName |
{ |
get |
{ |
return "Telerik.WinControls.UI.RadTabStrip"; |
} |
set |
{ |
base.ThemeClassName = value; |
} |
} |
After setting this up, I ran into a small issue. The theme appeared to still not be getting applied. Upon further inspection, I discovered a the issue was within RadTabWorkspace.cs. The background color and foreground color are actually being set on the RadTabWorkspace based on values provided by the SmartPartInfo. This is easily fixed by commenting out the following code in the SetTabProperties method of RadTabWorkspace.cs. (Note: This issue will be fixed in the next release of TCEK.)
//this.BackColor = smartPartInfo.BackColor; // this line |
this.Enabled = smartPartInfo.Enabled; |
//this.ForeColor = smartPartInfo.ForeColor; // this line |
this.Visible = smartPartInfo.Visible; |
this.Size = smartPartInfo.Size; |
Now the RadTabWorkspace control in your main layout should utilize the basic theme. You should also be able to apply any of the other themes provided with the Telerik controls.
Next week, I will go over the RadDockWorkspace. See you then!
Click here to download the source code used in this post.