If you look at the downloadable code, you will notice that
we have added an attribute to the Style properties and the ListItemCollection
properties:
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
The DesignerSerializationVisiblity attribute should be added
to public properties to specify whether those properties should be serialized
in the composite control at design time or not.
You still cannot see the picture here? We will show a code
snippet taken from a web form where the mover control has been added and the
BackColor of the left listbox has been set.
Listing 21
<cc1:bhMover id="BhMover1" runat="server">
<LeftListBoxStyle BackColor="Red"></LeftListBoxStyle>
</cc1:bhMover>
If you go back to the public property named LeftListBoxStyle,
you would see the above mentioned attribute specified. That attribute takes as
input an enumeration of type DesignerSerializationVisibility which has three
different values.
Visible: It forces the composite control to serialize the
designated property at design time and is mainly used for simple data type
properties.
Content: It forces the composite control to serialize the
designated property at design time and is mainly used for complex data types.
Hidden: It forces the composite control not to serialize the
designated property at design time.
Since the Style class is a complex data type, we have used
the Content value and the above code showed how the LeftListBoxStyle property
is serialized and rendered at design time once you place the composite control
on a web form.
More on the DesignerSerializationVisibility attribute can be
found in this article: Serialize
properties correctly with DesignerSerializationVisibilityAttribute.
You have also noticed the presence of another attribute,
PersistenceMode attribute. This attribute specifies how the property should be
persisted by the designer, i.e. whether the property will be shown as an attribute
or as a nested element with the property fields nested inside. This attribute
takes as input an enumeration of type PersistenceMode which has the following
values:
Attribute: The property will be persisted as an attribute on
the main composite control tag. This value is mainly used for simple data type
properties.
InnerProperty: The property will be persisted as a nested
element within the composite control tag. This value is mainly used for complex
data type properties.
More on this topic can be found at this article: Persist
properties correctly with PersistenceModeAttribute.
Hint: Once again you are advised to check the article
mentioned above by Miguel Castro, where we have came up with that idea of
serialization and other important ideas.