更改 WPF DatePicker 的字符串格式 [英] Changing the string format of the WPF DatePicker

查看:32
本文介绍了更改 WPF DatePicker 的字符串格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改 WPF Toolkit DatePicker 中 DatePickerTextBox 的字符串格式,以使用连字符代替斜线作为分隔符.

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 override this default culture or the display string format?

01-01-2010

推荐答案

我在这段代码的帮助下解决了这个问题.希望对大家有所帮助.

I have solved this problem with a help of this code. Hope it will help you all as well.

<Style TargetType="{x:Type DatePickerTextBox}">
 <Setter Property="Control.Template">
  <Setter.Value>
   <ControlTemplate>
    <TextBox x:Name="PART_TextBox"
     Text="{Binding Path=SelectedDate, StringFormat='dd MMM yyyy', 
     RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
   </ControlTemplate>
  </Setter.Value>
 </Setter>
</Style>

这篇关于更改 WPF DatePicker 的字符串格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆