Getting an "Items-Capacity" attribute without it being valid

M

Martijn Saly

Hi there,

I've been building a very simple "bread crumbs" control that has a
collection of BreadCrumb objects. Works pretty alright atm. There's just
this little thing that happens every now and then.

The control has an Items property which is defined as follows:

[Category("Behavior")]
[Editor(typeof(BreadCrumbCollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public BreadCrumbCollection Items {
get {
if (items == null)
items = new BreadCrumbCollection();
return items;
}
}

I've got this from an MSDN sample, so it should be good, I think. The
BreadCrumbCollection is just a List<BreadCrumb> and the
BreadCrumbCollectionEditor is a CollectionEditor descendant.

The funny thing is, everytime I add new BreadCrumb objects using the
designer, the control tag gets an attribute "Items-Capacity". This attribute
is not valid for the control tag, even though it appears automatically.

I've tried declaring the Capacity property inside the BreadCrumbCollection
as protected, and that does take care of the "Items-Capacity" attribute, but
it also prevents it from being called outside the class, which may not be
desirable.

Is there a better way to solve this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top