feat: update calendar min height

This commit is contained in:
rabbitism 2023-03-16 21:26:22 +08:00
parent 4a8f24767b
commit e101609534
3 changed files with 5 additions and 13 deletions

View File

@ -31,6 +31,7 @@
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem"> <ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem">
<Setter Property="CalendarItem.MinHeight" Value="{DynamicResource CalendarMinHeight}" />
<Setter Property="CalendarItem.DayTitleTemplate"> <Setter Property="CalendarItem.DayTitleTemplate">
<Template> <Template>
<TextBlock <TextBlock
@ -51,18 +52,13 @@
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<!--
To keep calendar from resizing when switching DisplayMode
In WinUI Min-Width from TemplateSettings
basically...MinWidth of DayItem = 40, 40 * 7 = 280 + margins/padding = ~294
Viewport height is set from # of rows displayed (2-8) in Month mode, = ~290 for 6 weeks (+ day names)
-->
<Grid <Grid
MinWidth="{DynamicResource CalendarMinWidth}" MinWidth="{DynamicResource CalendarMinWidth}"
MinHeight="{TemplateBinding MinHeight}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
RowDefinitions="Auto,*"> RowDefinitions="Auto,*">
<Grid ColumnDefinitions="Auto,*,Auto"> <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto">
<Button <Button
Name="PART_PreviousButton" Name="PART_PreviousButton"
Grid.Column="0" Grid.Column="0"
@ -98,15 +94,12 @@
Foreground="{DynamicResource CalendarItemIconForeground}" /> Foreground="{DynamicResource CalendarItemIconForeground}" />
</Button> </Button>
</Grid> </Grid>
<!-- Border below is used only for MonthView but it can't be moved inside of Grid because CalendarItem expects it to be empty and it will cause side-effects -->
<Grid <Grid
Name="PART_MonthView" Name="PART_MonthView"
Grid.Row="1" Grid.Row="1"
MinHeight="200"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
IsVisible="False"> IsVisible="False">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<!-- This should always be the week day names?? -->
<RowDefinition Height="{DynamicResource CalendarItemWeekDayNameHeight}" /> <RowDefinition Height="{DynamicResource CalendarItemWeekDayNameHeight}" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -128,7 +121,6 @@
<Grid <Grid
Name="PART_YearView" Name="PART_YearView"
Grid.Row="1" Grid.Row="1"
MinHeight="200"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
IsVisible="False"> IsVisible="False">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -152,7 +144,6 @@
<ControlTheme x:Key="{x:Type CalendarButton}" TargetType="CalendarButton"> <ControlTheme x:Key="{x:Type CalendarButton}" TargetType="CalendarButton">
<Setter Property="ClickMode" Value="Release" /> <Setter Property="ClickMode" Value="Release" />
<Setter Property="Margin" Value="2" /> <Setter Property="Margin" Value="2" />
<!-- These are actually set on the CalendarView in WinUI -->
<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}" />
@ -188,7 +179,6 @@
<Setter Property="ContentControl.Background" Value="{DynamicResource CalendarItemCalendarButtonPressedBackground}" /> <Setter Property="ContentControl.Background" Value="{DynamicResource CalendarItemCalendarButtonPressedBackground}" />
</Style> </Style>
<!-- Adjusted :selected to look like :today from DayItem -->
<Style Selector="^:selected"> <Style Selector="^:selected">
<Style Selector="^ /template/ ContentControl"> <Style Selector="^ /template/ ContentControl">
<Setter Property="ContentControl.Background" Value="{DynamicResource CalendarItemCalendarButtonSelectedBackground}" /> <Setter Property="ContentControl.Background" Value="{DynamicResource CalendarItemCalendarButtonSelectedBackground}" />

View File

@ -47,4 +47,5 @@
<SolidColorBrush x:Key="CalendarItemCalendarDayButtonInactiveForeground" Opacity="0.62" Color="#F9F9F9" /> <SolidColorBrush x:Key="CalendarItemCalendarDayButtonInactiveForeground" Opacity="0.62" Color="#F9F9F9" />
<sys:Double x:Key="CalendarMinWidth">240</sys:Double> <sys:Double x:Key="CalendarMinWidth">240</sys:Double>
<sys:Double x:Key="CalendarMinHeight">250</sys:Double>
</ResourceDictionary> </ResourceDictionary>

View File

@ -47,4 +47,5 @@
<SolidColorBrush x:Key="CalendarItemCalendarDayButtonInactiveForeground" Opacity="0.62" Color="#1C1F23" /> <SolidColorBrush x:Key="CalendarItemCalendarDayButtonInactiveForeground" Opacity="0.62" Color="#1C1F23" />
<sys:Double x:Key="CalendarMinWidth">240</sys:Double> <sys:Double x:Key="CalendarMinWidth">240</sys:Double>
<sys:Double x:Key="CalendarMinHeight">250</sys:Double>
</ResourceDictionary> </ResourceDictionary>