Items
我有一个具有属性的自定义控件。我已经应用了EditorAttribute
一个UITypeEditor
类型的CollectionEditor
。
收藏类型:
[Serializable]
[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
public class ListItemsCollection : CollectionBase
{
// methods
}
控件中的属性声明:
private new ListItemsCollection _Items;
[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
public new ListItemsCollection Items
{
get
{
return _Items;
}
set
{
_Items = value;
// do other UI changes
}
}
问题:
当我将此控件放到设计器表面时,我可以使用PropertyGrid
. 但是,当我单击属性设置器的Ok
按钮时,不会被调用。CollectionEditor
Items
AFAIK 当从类的EditValue
方法返回值时UITypeEditor
,应该调用属性的 setter 块。
这让我发疯。我什至尝试在 中添加Event
's ListItemsCollection
,以便在添加项目时,我可以使用控件的 ui 来做任何我想要的事情。
这应该不难。我究竟做错了什么?