I am translating a compact framework 2.0 windows form in Visual Studio 2005. To do that, I change the language of the form to German (the target language) and edit/resize the controls on the form. This creates a resources.de.resx file containing the translated strings as expected.
However, there is a custom control on the form, which has a property called GroupText, which must also be translated. However, the Form Designer refuses to use the resource files for this property. Whenever I change the property in the property editor, it gets changed for all languages. I checked the resx files - they do not contain the GroupText property, and the Designer generated code also does not use the resx file for this property.
Is there a way to enable resx-based, Visual Studio supported localization for custom controls as well?
Edit:
As an addition to the accepted answer, here's what you have to do to get resx files for custom controls to work.
Each property that should go into a resx file must have the Localizable
attribute set to true
. Now, the CF does not support this attribute via the usual bracket syntax. You cannot just write [Localizable=true]
in the cs source file. You have to create a separate file called DesignTimeAttributes.xmta
in the project and add the following:
<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
<Class Name="MyControl">
<Property Name="MyProperty">
<Localizable>true</Localizable>
</Property>
</Class>
Once you rebuild the assembly containing the control, Visual Studio will put the property values into resx files.