0

我有一种情况,我必须显示 DatePicker ,问题是我无法在顶部看到完整的月份名称,我只能看到像“D..”之后带有点的 12 月的第一位数字,而那里有足够的空间显示整个月份的名称。这是因为它从我不包括的 controltemplate 继承了许多样式的文本框/文本块。

在此处输入图像描述

这是我的尝试:

<DatePicker  
  FontSize="6"
  SelectedDate="{x:Static sys:DateTime.Now}" 
  HorizontalContentAlignment="Left">
</DatePicker>

<Style  TargetType="{x:Type DatePickerTextBox}" >
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <TextBox
                    x:Name="PART_TextBox"
                    HorizontalAlignment="Left"
                    VerticalContentAlignment="Center"                       
                    Text="{Binding Path=SelectedDate, ConverterCulture={x:Static glob:CultureInfo.InvariantCulture}, StringFormat={}{0:yyyy-MM-dd}, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="IsReadOnly" Value="True" />
</Style>
    <Style  TargetType="{x:Type DatePicker}">            
    <Setter Property="Background" Value="{StaticResource FlowWhiteBrush}" />
</Style>

如何修复它,以便我们通过在上面编写的模板中重写来覆盖以前的样式,并使其在左侧对齐,以便显示所有月份?但是要覆盖哪些样式和属性?

4

0 回答 0