Changing the string format of the WPF DatePicker

前端 未结 9 1776
广开言路
广开言路 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:35

    Converter class:

    public class DateFormat : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return null;
            return ((DateTime)value).ToString("dd-MMM-yyyy");
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    wpf tag

    
    

    Hope it helps

提交回复
热议问题