Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a pretty old question (marked somewhat incorrectly as "answered"). If you need to use a specific date format for the WPF DatePicker control but don't want to open up the source-code for it (which is, in fact, available for download), you can always specify the DateFormat of your entire UI, or set it for each DatePicker control.</p> <p>In my app, I used the following in Application_Startup event:</p> <pre><code>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 </code></pre> <p>Note that this will set the format for short-date-format everywhere in your app (which is what I wanted, rather than going through and applying the culture to each and every instance of a date-picker. I came up with the above based on another StackOverflow post; I don't remember exactly where it was (or I'd credit the author), but anyway, hope this helps!</p> <p>Kirk</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload