I am using DefaultValue attribute for the proper PropertyGrid behavior (it shows values different from default in bold). Now if I want to serialize
You could use two properties:
// For property grid only:
[Category(CategoryAnalyse)]
[TypeConverter(typeof(ConverterBoolOnOff))]
[DefaultValue(false)]
[XmlIgnore]
public bool AllowNegative
{
get { return _allowNegative; }
set
{
_allowNegative = value;
ConfigBase.OnConfigChanged();
}
}
// For serialization:
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[TypeConverter(typeof(ConverterBoolOnOff))]
[XmlElement("AllowNegative")]
public bool AllowNegative_XML
{
get { return _allowNegative; }
set
{
_allowNegative = value;
ConfigBase.OnConfigChanged();
}
}