I’ve been working on a small LoB application to manage sales of a small sales office. I thought it’d be a good idea to put to use my WPF knowledge and use WPF to create this application. The reason is obvious : Programming in WPF is as easy as it gets, more testable (as in Unit Testing and Acceptance Testing) and more end-user friendly.
Following applicaiton components and patterns were used:
- NHibernate Validator to validate both entities and ViewModels
- FarsiLibrary (globalizing Dates, DatePickers, etc.)
- MVVM pattern
One part that took more effort than expected was localization and globalization of the application. In general, there are three things you need to check to achieve full localization, if you provide both Left-To-Right reading order languages (English) as well as Right-To-Left (Farsi, Arabic) :
Thanks to WPF engine, most of the calculation of LTR reading order to RTL for Forms, UserControls and even Custom Controls is done automagically, although in custom controls, you might need to add some triggers to switch things like shadows, etc. and if you use a 3rd party custom control or library, you need to make sure component vendor has take care of issue like that.
WPF uses LocaBaml to extract localizable properties’ values to an excel file and after translation (e.g. assigning values for other languages), puts them in a satelite assembly. This approach looks rough to maintain but there are lots of libraries on Codeplex that will help you do this with xml files or .resx files. My suggestion is to use WPF Localization Extension which supports localizing FlowDirection, Brush, Texts, Images, etc.
Not eveyone use Gregorian Calendar available in english language cultures. For example in Arabic language HijriCalendar is used and for Farsi, PersianCalendar is used and sometimes just setting thread’s culture to the language (e.g. Farsi) would not be enough. If you use dates in your applications (who doesn’t?) you need to use date controls that work fluently with various languages and cultures. I used my own FarsiLibrary control for WPF which allows you to work with PersianCalendar, HijriCalendar and GregorianCalendar seamlessly.
With all the efforts and steps mentioned above, one part of the application still remains in native language of the Windows Installation. That is when using Windows’s MessageBox to alert user and display messages. Fortunately, I already have my Expression Clone styles which come with a Expression style messagebox that come with localizable icons / button texts.
No doubt one of the features that comes with WPF is the ability to style everything that makes sense to provide a better UX. I used my Expression styles which you can download here to style your WPF applications very easily to make it look like Expression series.