feat: remove Calendar BorderThickness.

(cherry picked from commit a909b6da6e9889bd19843d5d404c484997d7128f)
This commit is contained in:
Zhang Dian 2024-12-02 16:49:05 +08:00
parent 6c2c7ef846
commit bb85123884
2 changed files with 24 additions and 45 deletions

View File

@ -2,14 +2,12 @@
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"> x:CompileBindings="True">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type Calendar}" TargetType="Calendar"> <ControlTheme x:Key="{x:Type Calendar}" TargetType="Calendar">
<Setter Property="Foreground" Value="{DynamicResource CalendarForeground}" /> <Setter Property="Foreground" Value="{DynamicResource CalendarForeground}" />
<Setter Property="Background" Value="{DynamicResource CalendarBackground}" /> <Setter Property="Background" Value="{DynamicResource CalendarBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource CalendarBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource CalendarBorderThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource CalendarBorderThickness}" />
<Setter Property="Calendar.CornerRadius" Value="{DynamicResource CalendarCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource CalendarCornerRadius}" />
<Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template"> <Setter Property="Template">
@ -31,9 +29,9 @@
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem"> <ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem">
<Setter Property="CalendarItem.MinWidth" Value="{DynamicResource CalendarMinWidth}" /> <Setter Property="MinWidth" Value="{DynamicResource CalendarMinWidth}" />
<Setter Property="CalendarItem.MinHeight" Value="{DynamicResource CalendarMinHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource CalendarMinHeight}" />
<Setter Property="CalendarItem.DayTitleTemplate"> <Setter Property="DayTitleTemplate">
<Template> <Template>
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
@ -45,7 +43,7 @@
</Template> </Template>
</Setter> </Setter>
<Setter Property="CalendarItem.Template"> <Setter Property="Template">
<ControlTemplate TargetType="CalendarItem"> <ControlTemplate TargetType="CalendarItem">
<Border <Border
Padding="16" Padding="16"
@ -97,7 +95,8 @@
Name="PART_MonthView" Name="PART_MonthView"
Grid.Row="1" Grid.Row="1"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
IsVisible="False"> IsVisible="False"
ColumnDefinitions="*,*,*,*,*,*,*">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="{DynamicResource CalendarItemWeekDayNameHeight}" /> <RowDefinition Height="{DynamicResource CalendarItemWeekDayNameHeight}" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -107,33 +106,14 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid> </Grid>
<Grid <Grid
Name="PART_YearView" Name="PART_YearView"
Grid.Row="1" Grid.Row="1"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
IsVisible="False"> IsVisible="False"
<Grid.RowDefinitions> ColumnDefinitions="*,*,*,*"
<RowDefinition Height="*" /> RowDefinitions="*,*,*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</Grid> </Grid>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
@ -146,13 +126,14 @@
<Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonForeground}" />
<Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonBackground}" /> <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CalendarItemCalendarButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource CalendarItemCalendarButtonBorderBrush}" />
<Setter Property="CalendarButton.CornerRadius" Value="{DynamicResource CalendarItemCalendarButtonCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource CalendarItemCalendarButtonCornerRadius}" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="ClipToBounds" Value="False" /> <Setter Property="ClipToBounds" Value="False" />
<Setter Property="CalendarButton.HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="CalendarButton.VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="CalendarButton.HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="CalendarButton.VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="CalendarButton"> <ControlTemplate TargetType="CalendarButton">
<ContentControl <ContentControl
@ -213,6 +194,7 @@
<Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="CalendarDayButton"> <ControlTemplate TargetType="CalendarDayButton">
<ContentControl <ContentControl

View File

@ -3,8 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:CompileBindings="True"> x:CompileBindings="True">
<Design.PreviewWith> <Design.PreviewWith>
<StackPanel Margin="20" Width="300" Height="400"> <StackPanel Margin="20" Width="800" Height="400">
<CalendarDatePicker Classes="ClearButton" /> <CalendarDatePicker HorizontalAlignment="Center" Classes="ClearButton" />
</StackPanel> </StackPanel>
</Design.PreviewWith> </Design.PreviewWith>
<ControlTheme x:Key="{x:Type CalendarDatePicker}" TargetType="CalendarDatePicker"> <ControlTheme x:Key="{x:Type CalendarDatePicker}" TargetType="CalendarDatePicker">
@ -96,25 +96,22 @@
<Popup <Popup
Name="PART_Popup" Name="PART_Popup"
Grid.Column="0" Grid.Column="0"
HorizontalOffset="-8"
IsLightDismissEnabled="True" IsLightDismissEnabled="True"
PlacementTarget="{TemplateBinding}" Placement="BottomEdgeAlignedLeft"
VerticalOffset="-4"> PlacementTarget="{TemplateBinding}">
<Border <Border
Margin="8" Margin="4"
Background="Transparent"
BoxShadow="{DynamicResource CalendarDatePickerPopupBoxShadows}" BoxShadow="{DynamicResource CalendarDatePickerPopupBoxShadows}"
CornerRadius="{DynamicResource CalendarCornerRadius}"> CornerRadius="{DynamicResource CalendarCornerRadius}">
<Calendar <Calendar
Name="PART_Calendar" Name="PART_Calendar"
CornerRadius="{Binding $parent[Border].CornerRadius}" BorderThickness="0"
DisplayDate="{TemplateBinding DisplayDate}" DisplayDate="{TemplateBinding DisplayDate}"
DisplayDateEnd="{TemplateBinding DisplayDateEnd}" DisplayDateEnd="{TemplateBinding DisplayDateEnd}"
DisplayDateStart="{TemplateBinding DisplayDateStart}" DisplayDateStart="{TemplateBinding DisplayDateStart}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}"
SelectedDate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedDate, Mode=TwoWay}"> SelectedDate="{TemplateBinding SelectedDate, Mode=TwoWay}" />
</Calendar>
</Border> </Border>
</Popup> </Popup>
</Grid> </Grid>