Skip to content

Commit d340390

Browse files
committed
Fix Clock, CalendarWithClock and DateTimePicker
1 parent ef6c5d4 commit d340390

7 files changed

Lines changed: 60 additions & 9 deletions

File tree

dev/DevWinUI.Controls/Controls/Date/CalendarWithClock/CalendarWithClock.Property.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
namespace DevWinUI;
22
public partial class CalendarWithClock
33
{
4+
public CornerRadius ClockCornerRadius
5+
{
6+
get { return (CornerRadius)GetValue(ClockCornerRadiusProperty); }
7+
set { SetValue(ClockCornerRadiusProperty, value); }
8+
}
9+
10+
public static readonly DependencyProperty ClockCornerRadiusProperty =
11+
DependencyProperty.Register(nameof(ClockCornerRadius), typeof(CornerRadius), typeof(CalendarWithClock), new PropertyMetadata(new CornerRadius(0, 4, 4, 0)));
12+
13+
public CornerRadius CalendarViewCornerRadius
14+
{
15+
get { return (CornerRadius)GetValue(CalendarViewCornerRadiusProperty); }
16+
set { SetValue(CalendarViewCornerRadiusProperty, value); }
17+
}
18+
19+
public static readonly DependencyProperty CalendarViewCornerRadiusProperty =
20+
DependencyProperty.Register(nameof(CalendarViewCornerRadius), typeof(CornerRadius), typeof(CalendarWithClock), new PropertyMetadata(new CornerRadius(4, 0, 0, 4)));
21+
422
public ClockMode ClockMode
523
{
624
get { return (ClockMode)GetValue(ClockModeProperty); }

dev/DevWinUI.Controls/Controls/Date/Clock/Clock.Property.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
namespace DevWinUI;
22
public partial class Clock
33
{
4+
public static readonly DependencyProperty ClockCornerRadiusProperty =
5+
DependencyProperty.Register(nameof(ClockCornerRadius), typeof(CornerRadius), typeof(Clock), new PropertyMetadata(new CornerRadius(0)));
6+
public CornerRadius ClockCornerRadius
7+
{
8+
get { return (CornerRadius)GetValue(ClockCornerRadiusProperty); }
9+
set { SetValue(ClockCornerRadiusProperty, value); }
10+
}
11+
412
public static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register(
513
nameof(SelectedTime), typeof(DateTime), typeof(Clock), new PropertyMetadata(DateTime.Now, OnSelectedTimeChanged));
614
public DateTime SelectedTime

dev/DevWinUI.Controls/Controls/Date/DateTimePicker/DateTimePicker.Property.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,16 @@ public bool ShowConfirmButton
153153
}
154154

155155
public static readonly DependencyProperty ShowConfirmButtonProperty =
156-
DependencyProperty.Register(nameof(ShowConfirmButton), typeof(bool), typeof(DateTimePicker), new PropertyMetadata(true));
156+
DependencyProperty.Register(nameof(ShowConfirmButton), typeof(bool), typeof(DateTimePicker), new PropertyMetadata(true, OnShowConfirmButtonChanged));
157+
158+
private static void OnShowConfirmButtonChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
159+
{
160+
var ctl = (DateTimePicker)d;
161+
if (ctl != null)
162+
{
163+
ctl.UpdateTemplate();
164+
}
165+
}
157166

158167
public TimeSpan? SelectedTime
159168
{

dev/DevWinUI.Controls/Controls/Date/DateTimePicker/DateTimePicker.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,23 @@ private void UpdateTemplate()
160160
{
161161
FlyoutBorderThickness = new Thickness(1);
162162
FlyoutCornerRadius = new CornerRadius(4);
163+
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 4);
164+
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 4, 0);
163165
}
164166
else
165167
{
166168
FlyoutBorderThickness = new Thickness(0);
167169
FlyoutCornerRadius = new CornerRadius(0);
170+
if (ShowConfirmButton)
171+
{
172+
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 0);
173+
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 0, 0);
174+
}
175+
else
176+
{
177+
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 4);
178+
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 4, 0);
179+
}
168180
}
169181
}
170182
}

dev/DevWinUI.Controls/Themes/Generic.xaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Themes\Styles\Win2D\Watermark.xaml
438438
<Setter Property="Margin" Value="8,0" />
439439
<Setter Property="BorderBrush" Value="{ThemeResource CalendarViewBorderBrush}" />
440440
<Setter Property="Background" Value="{ThemeResource CalendarViewBackground}" />
441-
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
441+
<Setter Property="ClockCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
442442
<Setter Property="TitleBorderCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
443443
<Setter Property="TitleBorderBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
444444
<Setter Property="MinuteHandBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
@@ -459,7 +459,7 @@ Themes\Styles\Win2D\Watermark.xaml
459459
<Setter.Value>
460460
<ControlTemplate TargetType="local:Clock">
461461
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
462-
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" />
462+
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding ClockCornerRadius}" />
463463
<Grid>
464464
<Grid.RowDefinitions>
465465
<RowDefinition Height="53" />
@@ -3378,8 +3378,8 @@ Themes\Styles\Win2D\Watermark.xaml
33783378
</VisualStateGroup>
33793379
</VisualStateManager.VisualStateGroups>
33803380
<Border x:Name="Background" Grid.Column="0" Grid.ColumnSpan="2" MinHeight="32" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Control.IsTemplateFocusTarget="True" CornerRadius="{TemplateBinding CornerRadius}" />
3381-
<CalendarView x:Name="PART_CalendarView" Grid.Column="0" Margin="{TemplateBinding CalendarViewMargin}" BorderThickness="{TemplateBinding CalendarViewBorderThickness}" CalendarIdentifier="{TemplateBinding CalendarIdentifier}" CornerRadius="4,0,0,4" DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}" DisplayMode="{TemplateBinding DisplayMode}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}" IsOutOfScopeEnabled="{TemplateBinding IsOutOfScopeEnabled}" IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" MaxDate="{TemplateBinding MaxDate}" MinDate="{TemplateBinding MinDate}" Style="{TemplateBinding CalendarViewStyle}" />
3382-
<local:Clock x:Name="PART_Clock" Grid.Column="1" Margin="{TemplateBinding ClockMargin}" BorderThickness="{TemplateBinding ClockBorderThickness}" CornerRadius="0,4,4,0" />
3381+
<CalendarView x:Name="PART_CalendarView" Grid.Column="0" Margin="{TemplateBinding CalendarViewMargin}" BorderThickness="{TemplateBinding CalendarViewBorderThickness}" CalendarIdentifier="{TemplateBinding CalendarIdentifier}" CornerRadius="{TemplateBinding CalendarViewCornerRadius}" DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}" DisplayMode="{TemplateBinding DisplayMode}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}" IsOutOfScopeEnabled="{TemplateBinding IsOutOfScopeEnabled}" IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" MaxDate="{TemplateBinding MaxDate}" MinDate="{TemplateBinding MinDate}" Style="{TemplateBinding CalendarViewStyle}" />
3382+
<local:Clock x:Name="PART_Clock" Grid.Column="1" Margin="{TemplateBinding ClockMargin}" BorderThickness="{TemplateBinding ClockBorderThickness}" ClockCornerRadius="{TemplateBinding ClockCornerRadius}" />
33833383
</Grid>
33843384
</ControlTemplate>
33853385
<ControlTemplate x:Key="CalendarWithTimePickerTemplate" TargetType="local:CalendarWithClock">
@@ -6201,6 +6201,8 @@ Themes\Styles\Win2D\Watermark.xaml
62016201
<Setter Property="CalendarViewBorderThickness" Value="1" />
62026202
<Setter Property="ClockBorderThickness" Value="0,1,1,1" />
62036203
<Setter Property="ClockMode" Value="AnalogClock" />
6204+
<Setter Property="CalendarViewCornerRadius" Value="4,0,0,4" />
6205+
<Setter Property="ClockCornerRadius" Value="0,4,4,0" />
62046206
<Setter Property="Template" Value="{StaticResource CalendarWithAnalogClockTemplate}" />
62056207
</Style>
62066208
<Style BasedOn="{StaticResource DefaultCopyButtonStyle}" TargetType="local:CopyButton">

dev/DevWinUI.Controls/Themes/Styles/Controls/CalendarWithClockStyle.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<Setter Property="CalendarViewBorderThickness" Value="1" />
2323
<Setter Property="ClockBorderThickness" Value="0,1,1,1" />
2424
<Setter Property="ClockMode" Value="AnalogClock" />
25+
<Setter Property="CalendarViewCornerRadius" Value="4,0,0,4" />
26+
<Setter Property="ClockCornerRadius" Value="0,4,4,0" />
2527
<Setter Property="Template" Value="{StaticResource CalendarWithAnalogClockTemplate}" />
2628
</Style>
2729

@@ -123,7 +125,7 @@
123125
Margin="{TemplateBinding CalendarViewMargin}"
124126
BorderThickness="{TemplateBinding CalendarViewBorderThickness}"
125127
CalendarIdentifier="{TemplateBinding CalendarIdentifier}"
126-
CornerRadius="4,0,0,4"
128+
CornerRadius="{TemplateBinding CalendarViewCornerRadius}"
127129
DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}"
128130
DisplayMode="{TemplateBinding DisplayMode}"
129131
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
@@ -137,7 +139,7 @@
137139
Grid.Column="1"
138140
Margin="{TemplateBinding ClockMargin}"
139141
BorderThickness="{TemplateBinding ClockBorderThickness}"
140-
CornerRadius="0,4,4,0" />
142+
ClockCornerRadius="{TemplateBinding ClockCornerRadius}" />
141143
</Grid>
142144
</ControlTemplate>
143145

dev/DevWinUI.Controls/Themes/Styles/Controls/Clock.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<Setter Property="Margin" Value="8,0" />
3535
<Setter Property="BorderBrush" Value="{ThemeResource CalendarViewBorderBrush}" />
3636
<Setter Property="Background" Value="{ThemeResource CalendarViewBackground}" />
37-
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
37+
<Setter Property="ClockCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
3838
<Setter Property="TitleBorderCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
3939
<Setter Property="TitleBorderBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
4040
<Setter Property="MinuteHandBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
@@ -59,7 +59,7 @@
5959
<Border Background="{TemplateBinding Background}"
6060
BorderBrush="{TemplateBinding BorderBrush}"
6161
BorderThickness="{TemplateBinding BorderThickness}"
62-
CornerRadius="{TemplateBinding CornerRadius}" />
62+
CornerRadius="{TemplateBinding ClockCornerRadius}" />
6363
<Grid>
6464
<Grid.RowDefinitions>
6565
<RowDefinition Height="53" />

0 commit comments

Comments
 (0)