<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?哈哈