WPF Toolkit, Modified Date Format in DatePicker
the default date format in the DatePicker is "yyyy-mm-dd" but I need "dd-mm-yyyy". This one solution doesn't work for me.
source to share
This is a fairly old question (marked somewhat incorrectly as "answered"). If you need to use a specific date format for a WPF DatePicker control, but don't want to open source (which is actually downloadable) for it, you can always specify a DateFormat for the entire UI, or set it for each DatePicker control.
In my application, I used the following in the Application_Startup event:
Private Sub Application_Startup(ByVal sender As Object, ByVal e As System.Windows.StartupEventArgs) Handles MyBase.Startup
' other application initialization code here
Dim culInfo As Globalization.CultureInfo = New System.Globalization.CultureInfo("en-us")
Dim dtinfo As Globalization.DateTimeFormatInfo = New System.Globalization.DateTimeFormatInfo() With {
.ShortDatePattern = "dd-MMM-yyyy",
.ShortTimePattern = "hh:mm:ss tt",
.TimeSeparator = ":",
.MonthNames = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.MonthNames(),
.AbbreviatedMonthNames = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.AbbreviatedMonthNames(),
.DateSeparator = "-"}
culInfo.DateTimeFormat = dtinfo
System.Threading.Thread.CurrentThread.CurrentCulture = culInfo
Note that this will set the format for the concise format throughout the application (which is what I wanted, instead of going through and applying culture to each instance of the date picker above, based on another StackOverflow post, I don't remember exactly where he was (or I would name the author) but hope this helps anyway!
Kirk
source to share