WPF -- 设置 DatePicker 的日期时间显示格式

参考:《Changing the string format of the WPF DatePicker》

 

XAML代码:

 

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

 

 

 

你可能感兴趣的:(format,Datepicker,WPF)