Somewhere else, someone states that the “Visible” Property of a control cannot be localized. This is half-true. However, the “Visible” Property has the LocalizableAttribute set to true. But this just means that the property is serialized to the resource file. I wrote a test program that has the visible property of a label set to “false” for the Invariant Culture. Making the form localizable I changed the visible property to “true” for the German culture. Now what happens if I start the program with the system set to German locale? The label stays invisible.
Checking the resource file Form1.de.resx I can see that the visible property has not been serialized. But if I manually add this to the resource file:
<data name="label1.Visible" type="System.Boolean, mscorlib">
<value>True</value>
</data>
the label appears. I confess to be slightly confused.
Two questions:
- How can I detect if a property is “truly” localizable using the build-in serializer?
- What is the recommended way to override the default behaviour?
Edit:
Maybe I need to clarify my question.
My sample program is a simple form which has the default language set to invariant. I have manually added german resources through the forms designer. Program runs on a system with regional settings set to german.
Case 1
“Visible” Property of a panel added to the form:
1.) set to false in Invariant culture, true (default) in german culture. => panel is invisible
2.) set to true in Invariant culture, false in german culture. => panel is invisible (works as expected)
Apparently the value is only written to the language specific resource file if it’s not the default.
Case 2
“Font” Property of a label added to the form:
1.) set to bold in Invariant culture, Property is reset to default in german culture. => label is not bold
2.) set to default in Invariant culture, bold in german culture. => label is bold
Now here the properties are serialized as expected.
Is it a bug or am I missing something?
We have received a response from Microsoft:
So the answer is: There is currently no solution.