Creating the designer
Creating a custom control
The backbone of the designer is a custom control. It allows you to wrap existing designer views into a multi view designer. The custom control can reside either in the project of the targeted control or in a separate project. Because the designers are usually coupled to a specific control, it is better to create the designer in the same project as the control. To create the class for the designer, perform the following.
-
Add a new class to the project of your control.
For example, if your control is named Rotator, create a class named RotatorDesigner.
-
Add a reference to the Telerik.Sitefinity assembly.
The assembly can be found under the C:\Program Files (x86)\Telerik\Sitefinity 4.0\Libraries folder.
-
Add a reference to the System.Web.Extensions assembly.
The assembly can be found under the .NET tab of the Add Reference dialog.
- Add the using Telerik.Sitefinity.Web.UI.ControlDesign; statement to the RotatorDesigner class.
-
Make the RotatorDesigner class inherit the ContentViewDesignerBase class.
public class RotatorDesigner : ContentViewDesignerBase
{
}
Overriding the AddViews method
To specify the views you want to display in your designer, perform the following:
-
Override the AddViews method of the base class.
public class RotatorDesigner1 : ContentViewDesignerBase
{
protected override void AddViews(Dictionary<string, ControlDesignerView> views)
{
}
}
-
You must add the views to the views argument it receives:
public class RotatorDesigner1 : ContentViewDesignerBase
{
protected override void AddViews(Dictionary<string, ControlDesignerView> views)
{
views.Add("View1", new DesignerView1());
}
}
Overriding the ResourceAssemblyInfo property
The ContentViewDesignerBase class uses a predefined template for its UI. It is located in the Telerik.Sitefinity.Resources assembly. The ContentViewDesignerBase uses the ResourceAssemblyInfo property to locate its resources. You must override the property to return a type form the Telerik.Sitefinity.Resources assembly. To do it, perform the following:
-
Add a reference to the Telerik.Sitefinity.Resources assembly.
The assembly can be found under the C:\Program Files (x86)\Telerik\Sitefinity 4.0\Libraries folder.
-
Override the ResourceAssemblyInfo property to return the type of the Reference class.
protected override Type ResourcesAssemblyInfo
{
get
{
return typeof(Telerik.Sitefinity.Resources.Reference);
}
}
Overriding the ScriptDescriptorTypeName property
Override the ScriptDescriptorTypeName to the following:
protected override string ScriptDescriptorTypeName
{
get
{
return typeof(ContentViewDesignerBase).FullName;
}
}
By default it returns the full name of the current object class. By overriding it, you reuse the script of the base class. If you want to specify a new script for your designer, do not override the property.