Changing the string format of the WPF DatePicker

前端 未结 9 1782
广开言路
广开言路 2020-11-27 14:56

I need to change the string format of the DatePickerTextBox in the WPF Toolkit DatePicker, to use hyphens instead of slashes for the seperators.

Is there a way to ov

9条回答
  •  隐瞒了意图╮
    2020-11-27 15:45

    It appears, as per Wonko's answer, that you cannot specify the Date format in Xaml format or by inheriting from the DatePicker.

    I have put the following code into my View's constructor which overrides the ShortDateFormat for the current thread:

    CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);
    ci.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
    Thread.CurrentThread.CurrentCulture = ci;
    

提交回复
热议问题