回答可能有点晚,但幸运的是,当时我偶然发现了Anders Hattestad 的文章。天才的家伙,对 EpiServer 有很好的洞察力。
我继承了他的控件并制作了很多我自己的控件,它们就像一个魅力。
谢谢。
编辑:
应比尔的要求,这是最终代码。文章链接已经放在上面了:)
using System;
using System.Collections.Generic;
using System.Text;
using EPiServer.Core;
using System.Web.UI.WebControls;
using System.Web.UI;
using EPiServer.PlugIn;
using Itera.Property;
using EPiServer.SpecializedProperties;
namespace MyProject.CustomProperties
{
[PageDefinitionTypePlugIn]
public class CategoryList : PropertyMulitBase
{
public CategoryList()
: base()
{
EditOption.Add(EditOptions.ShowTopTabs, true);
}
#region BasePropertys
PropertyDataCollection basePropertys;
public override EPiServer.Core.PropertyDataCollection BasePropertys
{
get
{
if (basePropertys == null)
{
PropertyDataCollection _new = new PropertyDataCollection();
_new.Add("Category", new Category());
basePropertys = _new;
}
return basePropertys;
}
}
#endregion
}
[PageDefinitionTypePlugIn]
public class CategoryItemList : PropertyMulitBase
{
public CategoryItemList()
: base()
{
EditOption.Add(EditOptions.ShowTopTabs, true);
}
#region BasePropertys
PropertyDataCollection basePropertys;
public override EPiServer.Core.PropertyDataCollection BasePropertys
{
get
{
if (basePropertys == null)
{
PropertyDataCollection _new = new PropertyDataCollection();
_new.Add("Category Item", new PropertyPageReference());
basePropertys = _new;
}
return basePropertys;
}
}
#endregion
}
public class Category : PropertySingleBase
{
#region PropertyCollection
PropertyDataCollection innerPropertyCollection;
object lockObject = new object();
protected override PropertyDataCollection InnerPropertyCollection
{
get
{
if (innerPropertyCollection == null)
{
innerPropertyCollection = new PropertyDataCollection();
innerPropertyCollection.Add("Category", new PropertyPageReference());
innerPropertyCollection.Add("Customise", new PropertyBoolean());
innerPropertyCollection.Add("Category Item", new CategoryItemList());
}
return innerPropertyCollection;
}
set
{
innerPropertyCollection = value;
}
}
#endregion
}
}
将此添加到项目下的 CustomProperties 文件夹中。