WPF Calendar 修改星期几显示内容

  <CalendarConverters:CalendarItemConverter x:Key="CalendarItemConverter"/>
    <Style x:Key="CalendarItemStyle" TargetType="{x:Type CalendarItem}">
        <Setter Property="Margin"
          Value="0,3,0,3" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarItem}">
                    <ControlTemplate.Resources>
                        <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                            <TextBlock Foreground="#FF333333"
                       FontWeight="Bold"
                       FontSize="9.5"
                       FontFamily="Verdana"
                       Margin="0,6,0,6"
                       Text="{Binding Converter={StaticResource CalendarItemConverter}}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"/>
                        </DataTemplate>
                    </ControlTemplate.Resources>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
public class CalendarItemConverter : IValueConverter
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="value"></param>
    /// <param name="targetType"></param>
    /// <param name="parameter"></param>
    /// <param name="culture"></param>
    /// <returns></returns>
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is string realValue)
        {
            switch (realValue)
            {
                case "":
                    return "";
                case "":
                    return "";
                case "":
                    return "";
                case "":
                    return "";
                case "":
                    return "";
                case "":
                    return "";
                case "":
                    return "";
            }
        }

        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

 

posted @ 2024-11-22 15:26  苏秦与真相  阅读(5)  评论(0编辑  收藏  举报