|
| 1 | +<UserControl xmlns="https://github.com/avaloniaui" |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:controls="using:PiTouchDate.Controls" |
| 4 | + x:Class="PiTouchDate.Controls.Calendar" |
| 5 | + x:Name="CalRoot"> |
| 6 | + |
| 7 | + <UserControl.Styles> |
| 8 | + |
| 9 | + <!-- Custom template for day buttons: full control over hover/today/selected states --> |
| 10 | + <Style Selector="Button.day"> |
| 11 | + <Setter Property="HorizontalAlignment" Value="Stretch"/> |
| 12 | + <Setter Property="VerticalAlignment" Value="Stretch"/> |
| 13 | + <Setter Property="HorizontalContentAlignment" Value="Center"/> |
| 14 | + <Setter Property="VerticalContentAlignment" Value="Center"/> |
| 15 | + <Setter Property="Padding" Value="0"/> |
| 16 | + <Setter Property="Margin" Value="1"/> |
| 17 | + <Setter Property="FontSize" Value="12"/> |
| 18 | + <Setter Property="Foreground" Value="{DynamicResource SemiGrey5Color}"/> |
| 19 | + <Setter Property="Background" Value="Transparent"/> |
| 20 | + <Setter Property="BorderThickness" Value="0"/> |
| 21 | + <Setter Property="Template"> |
| 22 | + <Setter.Value> |
| 23 | + <ControlTemplate TargetType="Button"> |
| 24 | + <Border Name="DayBg" |
| 25 | + Background="{TemplateBinding Background}" |
| 26 | + CornerRadius="6" |
| 27 | + HorizontalAlignment="Stretch" |
| 28 | + VerticalAlignment="Stretch"> |
| 29 | + <ContentPresenter HorizontalAlignment="Center" |
| 30 | + VerticalAlignment="Center" |
| 31 | + Content="{TemplateBinding Content}" |
| 32 | + Foreground="{TemplateBinding Foreground}"/> |
| 33 | + </Border> |
| 34 | + </ControlTemplate> |
| 35 | + </Setter.Value> |
| 36 | + </Setter> |
| 37 | + </Style> |
| 38 | + |
| 39 | + <Style Selector="Button.day:pointerover /template/ Border#DayBg"> |
| 40 | + <Setter Property="Background" Value="#20FFFFFF"/> |
| 41 | + </Style> |
| 42 | + |
| 43 | + <!-- Today: blue background — overrides hover --> |
| 44 | + <Style Selector="Button.day.today /template/ Border#DayBg"> |
| 45 | + <Setter Property="Background" Value="{DynamicResource SemiBlue4Color}"/> |
| 46 | + </Style> |
| 47 | + |
| 48 | + <!-- Today: white text --> |
| 49 | + <Style Selector="Button.day.today"> |
| 50 | + <Setter Property="Foreground" Value="White"/> |
| 51 | + </Style> |
| 52 | + |
| 53 | + <!-- Days from adjacent months: dimmed --> |
| 54 | + <Style Selector="Button.day.otherMonth"> |
| 55 | + <Setter Property="Opacity" Value="0.35"/> |
| 56 | + </Style> |
| 57 | + |
| 58 | + </UserControl.Styles> |
| 59 | + |
| 60 | + <Grid RowDefinitions="Auto, Auto, *, Auto"> |
| 61 | + |
| 62 | + <!-- Header: ‹ Maggio 2026 › --> |
| 63 | + <Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto" Margin="0,0,0,6"> |
| 64 | + <Button Grid.Column="0" Classes="Link" Padding="8,4" Background="Transparent" |
| 65 | + Command="{Binding #CalRoot.PreviousMonthCommand}"> |
| 66 | + <PathIcon Data="{DynamicResource SemiIconChevronLeft}" Width="14" Height="14"/> |
| 67 | + </Button> |
| 68 | + <TextBlock Grid.Column="1" |
| 69 | + Text="{Binding #CalRoot.HeaderText}" |
| 70 | + HorizontalAlignment="Center" VerticalAlignment="Center" |
| 71 | + FontWeight="SemiBold" FontSize="13"/> |
| 72 | + <Button Grid.Column="2" Classes="Link" Padding="8,4" Background="Transparent" |
| 73 | + Command="{Binding #CalRoot.NextMonthCommand}"> |
| 74 | + <PathIcon Data="{DynamicResource SemiIconChevronRight}" Width="14" Height="14"/> |
| 75 | + </Button> |
| 76 | + </Grid> |
| 77 | + |
| 78 | + <!-- Day-of-week labels, Monday-first (Italian) --> |
| 79 | + <Grid Grid.Row="1" ColumnDefinitions="*,*,*,*,*,*,*" Margin="0,0,0,2"> |
| 80 | + <TextBlock Grid.Column="0" Text="L" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 81 | + <TextBlock Grid.Column="1" Text="M" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 82 | + <TextBlock Grid.Column="2" Text="M" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 83 | + <TextBlock Grid.Column="3" Text="G" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 84 | + <TextBlock Grid.Column="4" Text="V" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 85 | + <TextBlock Grid.Column="5" Text="S" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 86 | + <TextBlock Grid.Column="6" Text="D" HorizontalAlignment="Center" Opacity="0.45" FontSize="10"/> |
| 87 | + </Grid> |
| 88 | + |
| 89 | + <!-- 6×7 day grid --> |
| 90 | + <ItemsControl Grid.Row="2" ItemsSource="{Binding #CalRoot.Days}"> |
| 91 | + <ItemsControl.ItemsPanel> |
| 92 | + <ItemsPanelTemplate> |
| 93 | + <UniformGrid Columns="7" Rows="6"/> |
| 94 | + </ItemsPanelTemplate> |
| 95 | + </ItemsControl.ItemsPanel> |
| 96 | + <ItemsControl.ItemTemplate> |
| 97 | + <DataTemplate DataType="controls:CalendarDay"> |
| 98 | + <Button Classes="day" |
| 99 | + Classes.today="{Binding IsToday}" |
| 100 | + Classes.otherMonth="{Binding IsOtherMonth}" |
| 101 | + Content="{Binding DayNumber}"/> |
| 102 | + </DataTemplate> |
| 103 | + </ItemsControl.ItemTemplate> |
| 104 | + </ItemsControl> |
| 105 | + |
| 106 | + <!-- Return to today --> |
| 107 | + <Button Grid.Row="3" Classes="Link" |
| 108 | + Content="Oggi" |
| 109 | + Command="{Binding #CalRoot.GoToTodayCommand}" |
| 110 | + HorizontalAlignment="Center" |
| 111 | + Background="Transparent" |
| 112 | + Margin="0,4,0,0"/> |
| 113 | + |
| 114 | + </Grid> |
| 115 | +</UserControl> |
0 commit comments