• WPF设置DatePicker日期格式之卡Bug大法


            <DatePicker Name="picker" Grid.Column="5" Grid.Row="0" SelectedDate="{Binding Patient.Birthday, StringFormat=yyyy-MM-dd, Converter={StaticResource DateConverter}}" VerticalAlignment="Center" SelectedDateChanged="DatePicker_SelectedDateChanged" BorderThickness="0" Style="{DynamicResource DatePickerStyle1}">
                <DatePicker.Resources>
                    <Style TargetType="DatePickerTextBox">
                        <Setter Property="BorderThickness" Value="0"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <TextBox x:Name="PART_TextBox" Text="{Binding Path=SelectedDate, StringFormat={}{0:yyyy-MM-dd}, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DatePicker.Resources>
            </DatePicker>

    Style="{DynamicResource DatePickerStyle1}",标红的样式, 是不存在的。

    试了半天,没成功,无意中碰到了这个bug?哈哈

  • 相关阅读:
    Lc169_多数元素
    Lc461_汉明距离
    有返回值的多线程
    Lc344_反转字符串
    Lc709_转换成小写字母
    Lc1436_旅行终点站
    Spring 注解回顾
    SpringCloud网关之Zuul
    SpringCloud注册中心之Zookeeper
    SpringCloud服务安全之hystrix
  • 原文地址:https://www.cnblogs.com/usen521/p/16004177.html
Copyright © 2020-2023  润新知