Creating the designer

The multi view control designer uses a one or more views to display its UI. The designer is represented by a custom control that inherits the ContentViewDesignerBase class. In it you must specify a collection of the views you want to display in it.

To create a multi view control designer for your control, you must perform the following:

  1. Create a custom control
  2. Override the AddViews method
  3. Override the ResourceAssemblyInfo property
  4. Override the ScriptDescriptorTypeName property

TIP: For more information about creating views for the multi view control designer, see Creating a view.

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.

  1. Add a new class to the project of your control.

    For example, if your control is named Rotator, create a class named RotatorDesigner.

  2. 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.

  3. Add a reference to the System.Web.Extensions assembly.

    The assembly can be found under the .NET tab of the Add Reference dialog.

  4. Add the using Telerik.Sitefinity.Web.UI.ControlDesign; statement to the RotatorDesigner class.
  5. 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:

  1. Override the AddViews method of the base class.

    public class RotatorDesigner1 : ContentViewDesignerBase
    {
        protected override void AddViews(Dictionary<string, ControlDesignerView> views)
        {
     
        }
    }
  2. 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:

  1. 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.

  2. 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.

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK