detect/detect.gui/Assets/CalendarDatePicker.axaml
2024-11-13 17:09:15 +08:00

145 lines
6.6 KiB
XML

<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="CalendarDatePicker">
<Setter Property="Foreground" Value="{DynamicResource CalendarDatePickerForeground}" />
<Setter Property="BorderThickness" Value="{DynamicResource CalendarDatePickerBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="4" />
<Setter Property="Template">
<ControlTemplate>
<DataValidationErrors>
<Panel x:Name="LayoutRoot"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Border x:Name="Background"
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}" />
<Grid ColumnDefinitions="*,Auto">
<TextBox Name="PART_TextBox"
Foreground="{TemplateBinding Foreground}"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
CornerRadius="{TemplateBinding CornerRadius}"
Margin="4, 1, 1, 1"
Padding="{TemplateBinding Padding}"
Watermark="{TemplateBinding Watermark}"
UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Focusable="False"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Grid.Column="0">
<TextBox.Styles>
<Style Selector="TextBox#PART_TextBox:pointerover">
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="TextBox#PART_TextBox:focus">
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style Selector="TextBox#PART_TextBox:focus /template/ Border#PART_BorderElement">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="TextBox#PART_TextBox:disabled">
<Style Selector="^ /template/ Border#PART_BorderElement">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^ /template/ TextBlock#PART_Watermark, ^ TextBlock#PART_FloatingWatermark">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CalendarDatePickerTextForegroundDisabled}" />
</Style>
</Style>
</TextBox.Styles>
</TextBox>
<Button Name="PART_Button"
Margin="2,0,4,0"
Width="24"
Height="20"
Grid.Column="1"
Focusable="False">
<Button.Template>
<ControlTemplate>
<PathIcon Width="12"
Height="12"
Foreground="#FFFFFF"
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" />
</ControlTemplate>
</Button.Template>
</Button>
<Popup Grid.Column="0"
Name="PART_Popup"
PlacementTarget="{TemplateBinding}"
IsLightDismissEnabled="True">
<Calendar Name="PART_Calendar"
CornerRadius="6, 6, 0, 0"
Margin="0, 5, 0, 0"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}"
SelectedDate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedDate, Mode=TwoWay}"
DisplayDate="{TemplateBinding DisplayDate}"
DisplayDateStart="{TemplateBinding DisplayDateStart}"
DisplayDateEnd="{TemplateBinding DisplayDateEnd}" />
</Popup>
</Grid>
</Panel>
</DataValidationErrors>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="CalendarDatePicker.filter">
<Setter Property="FontFamily" Value="{StaticResource Font-Family}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.2" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.3" />
</Setter.Value>
</Setter>
<Setter Property="CornerRadius" Value="6" />
<!-- Pointer-over State -->
<Style Selector="^:pointerover /template/ Border#Background">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.3" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.4" />
</Setter.Value>
</Setter>
</Style>
<!-- Focused State -->
<Style Selector="^:focus-within:not(CalendarDatePicker:focus) /template/ Border#Background">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.3" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="#2D77F3" Opacity="0.4" />
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="1" />
</Style>
</Style>
</Styles>