It is normal to have properties in your control or component whose default values are inherited from a base class control or component.
In such cases you will normally prevent the designer from storing the property's value in code (using either DefaultValue attribute or the ShouldSerializeXXX pattern). However, if that property is Localizable and Localization is turned on, then the property's value will be forced to be stored in the resource. This will break your property-inheritance logic.
For example:
[ Localizable( true ) ]
public Font ButtonFont
{
get
{ return buttonFont == null ? Font : buttonFont; }
set
{ buttonFont = value; }
}
private bool ShouldSerializeButtonFont()
{
return ButtonFont != Font;
}
In the above case the ButtonFont inherits its value from the Font property, if its value is not set. And you use null to determine whether the value is set or not.
But when Localization is on, the property gets set and you lose the inheritance logic.
You can avoid this by specifying an AmbientValue attribute for your property, as follows:
[ Localizable( true ), AmbientValue( null ) ]
public Font ButtonFont { /* ... */ }
This will use the AmbientValue as the value to persist when there is default value in your property. This will prevent your property from getting set unnecessarily.
Contributed from George Shepherd's Windows Forms FAQ