Search code examples
silverlightlocalizationdatapager

Silverlight DataPager localization


Is it possible to localize DataPager's footer (Page X of Y) in Silvelright?

The strings seem to be located in resources embedded in the assembly of DataPager. So how should I localize it?

Unfortunately, almost nothing in the DataPager class is virtual and also many internal classes are used by it, so it is not possible (at least easily) to inherit DataPager and override the behavior.


Solution

  • So, there is another solution - changing the resources in the DLL.

    The solution is based on this article.

    Since the System.Controls.Data.dll is signed by MS, I needed to remove the signature (strong name). I used AdmiralDebilitate to remove it.

    1. Copy System.Controls.Data.dll to a temp folder.
    2. Use AdmiralDebilitate to open the dll, click Mark All and then Apply changes. This should remove the strong name that would prevent the patched dll with custom resources to work.
    3. Open Visual Studio Command Prompt in the temp folder.
    4. Disassemble the dll by command

      ildasm /out=System.Controls.Data.il System.Controls.Data.dll

    5. Use any resource editor (I used Resource.net) to open System.Windows.Controls.DataPager.PagerResources.resources.

    6. Edit the resource strings you want. Save the resource file and close the editor.
    7. Reassemble the assembly by command

      ilasm /resource=System.Controls.Data.res /dll /output=System.Controls.Data.dll System.Controls.Data.il

    8. Done.

    There are two possible problems:

    • You must make sure that VS uses this DLL and not the original one from GAC. This can be ensured by opening the .csproj file in notepad and checking the reference path.
    • If you use any other MS assemblies that are dependent on the patched one, you will need to patch them too (AdmiralDebilitate should help).