How does one tell the designer the default value of a Property when it is not one of the types supported by DefaultValue()
? For instance, a Padding
, or
Try this:
private static Padding DefaultLabelPadding = new Padding(2);
private internalLabelPadding = DefaultLabelPadding;
public Padding LabelPadding { get { return internalLabelPadding; } set { internalLabelPadding = value; LayoutNow(); } }
// next comes the magic
bool ShouldSerializeLabelPadding() { return LabelPadding != DefaultLabelPadding; }
The property browser looks for a function named ShouldSerializeXYZ
for each property XYZ
. Whenever ShouldSerializeXYZ
returns false, it doesn't write anything during code generation.
EDIT: documentation: