- Create your DatePicker application described in this article or your own application.
- Insert in MainPage.xaml.cs
using System.Globalization; using System.Threading;
- Windows Phone supports the display languages you may find here
- Next code fragment do all you need (of course you must choose "Culture code" you need):
public MainPage() { CultureInfo newCulture = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentCulture = newCulture; Thread.CurrentThread.CurrentUICulture = newCulture; ... }
- But if your language not supported by windows phone?
public MainPage() { CultureInfo newCulture = new CultureInfo("en-GB"); //change format of DatePicker to you own format newCulture.DateTimeFormat.ShortDatePattern = "d/MMM/yyyy"; //set day names newCulture.DateTimeFormat.DayNames = new string[] { "first day", "second day", "third day", "4 day", "5 day", "6 day", "7 day" }; //set month names newCulture.DateTimeFormat.MonthNames = new string[] {"1 month", "2 month", "3 month", "4 month", "5 month", "6 month", "7 month", "8 month", "9 month", "10 month", "11 month", "12 month", ""}; Thread.CurrentThread.CurrentCulture = newCulture; Thread.CurrentThread.CurrentUICulture = newCulture; ... }
- Enjoy
WP7: How to Localize you DatePicker
Subscribe to:
Post Comments (Atom)
very good your post! thank's...
ReplyDelete