从Calendar WPF样式中删除此边框线

时间:2017-06-07 16:08:24

标签: wpf

可以从WPF日历中删除此边框线吗?

我尝试了一个简单的示例xaml和相同的效果:

<Grid >
    <StackPanel Orientation="horizontal" >
        <Calendar BorderThickness="0px" Background="Beige" Foreground="Beige" BorderBrush="Beige"                                
              SelectedDate="6/4/2017" 
              DisplayDate="6/4/2017" DisplayDateStart="5/1/1900" DisplayDateEnd="7/1/3000" 
              DisplayMode="Month"
            />
    </StackPanel>
</Grid>

border white line

1 个答案:

答案 0 :(得分:0)

我认为你可能需要修改模板。它是内边框上CalendarItem样式的一部分。

<Style x:Key="CalendarItemStyle1" TargetType="{x:Type CalendarItem}">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <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" HorizontalAlignment="Center" Margin="0,6,0,6" Text="{Binding}" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </ControlTemplate.Resources>
                    <Grid x:Name="PART_Root">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="DisabledColor" Color="#A5FFFFFF"/>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_DisabledVisual"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1">

// get rid of the border thickness here and it's gone
                            <Border BorderBrush="Purple" BorderThickness="2" CornerRadius="1">
                                <Grid>
                                    <Grid.Resources>
                                        <ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}">