We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Platform : WinForms
Category : Serialization

How do I prevent the default values of my Localized properties form being set?

It is normal to have Properties in your Control/Component whose default values are inherited from some other Control/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:

In the above case the MyControlButtonFont 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:

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.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon