How can we create a multilingual application in WPF?
This code is developed in VS2012.
Using the Code
Create a new WPF Application Project. By default, you will get App.xaml & MainWindow.xaml forms.
Now create a new
ClassLibrary project in the same solution for resource files. You can also create resource files in the same project.
And add Resource files in that
ClassLibrary. I have added 2 in my project named as Language.resx (for English) and Language.de-DE.resx (for German). Mention your lables, buttons, etc. translations in those files. And make the Access Modifier as PUBLIC.
Build your class Library and add reference in WPF project.
Now open App.xaml code behind and write the below lines in default constructor:
By default, I have mentioned
de-DE as culture. For English, you can leave it blank.
Now open MainWindow.xaml and design the page as per your requirement. But add the namespace of class library in Window tag as per below:
Now bind the controls as per their content, as per below screen:
And now run the application. That's it................enjoy programming.
Having working experience of 8+ Years in IT , major experience is in Banking/Finance , Engineering, e-Commerce web development.