Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Navigation [hide] [expand]

Introduction

The following example shows how to create the component container used for adding personalized gadgets:

CopyC#
using System;
using System.Collections.Generic;

namespace EPiServer.Shell.ViewComposition.Containers
{
    /// <summary>
    /// An extension of the grid container providing component management
    /// </summary>
    [Component(IsAvailableForUserSelection = false)]
    public class ComponentContainer : ContainerBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentContainer"/> class.
        /// </summary>
        public ComponentContainer() : base("epi.shell.widget.layout.ComponentContainer") { }

        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentContainer"/> class.
        /// </summary>
        protected ComponentContainer(string widgetType) : base(widgetType)
        { 
            Settings.Add(new Setting("numberOfColumns", 1));
            Settings.Add(new Setting("showToolbar", true));
            Settings.Add(new Setting("containerUnlocked", false));
            Settings.Add(new Setting("closable", false));
            Settings.Add(new PersonalizableSetting("componentCategory"));
        }

        /// <summary>
        /// Gets or sets a comma seperated string of categories that this component can have as children.
        /// </summary>
        public virtual string ComponentCategory
        {
            get
            {
                return Settings["componentCategory"] as string;
            }
            set
            {
                Settings["componentCategory"] = value;
            }
        }
    }
}

Last updated: Mar 21, 2013