Skip to content

Commit 9b3c88d

Browse files
committed
Add ClearColor Property for Countdown
1 parent 464022c commit 9b3c88d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

dev/DevWinUI.Controls/Controls/Win2D/Countdown/Countdown.Properties.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace DevWinUI;
1+

2+
3+
namespace DevWinUI;
24

35
public partial class Countdown
46
{
@@ -125,6 +127,24 @@ public IList<RadialGradientStopData> ErrorBackgroundGradientStops
125127
public static readonly DependencyProperty ErrorBackgroundGradientStopsProperty =
126128
DependencyProperty.Register(nameof(ErrorBackgroundGradientStops), typeof(IList<RadialGradientStopData>), typeof(Countdown), new PropertyMetadata(null, OnPropertyChanged));
127129

130+
public Color ClearColor
131+
{
132+
get { return (Color)GetValue(ClearColorProperty); }
133+
set { SetValue(ClearColorProperty, value); }
134+
}
135+
136+
public static readonly DependencyProperty ClearColorProperty =
137+
DependencyProperty.Register(nameof(ClearColor), typeof(Color), typeof(Countdown), new PropertyMetadata(Colors.Transparent, OnClearColorChanged));
138+
139+
private static void OnClearColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
140+
{
141+
var ctl = (Countdown)d;
142+
if (ctl != null)
143+
{
144+
ctl.UpdateClearColor();
145+
}
146+
}
147+
128148
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
129149
{
130150
var ctl = (Countdown)d;

dev/DevWinUI.Controls/Controls/Win2D/Countdown/Countdown.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ protected override void OnApplyTemplate()
4545
base.OnApplyTemplate();
4646
canvas = GetTemplateChild(PART_Canvas) as CanvasAnimatedControl;
4747

48+
UpdateClearColor();
49+
4850
if (BackgroundGradientStops == null || BackgroundGradientStops.Count == 0)
4951
{
5052
var startColor = Color.FromArgb(0x00, 0x6E, 0xEF, 0xF8);
@@ -101,7 +103,13 @@ protected override void OnApplyTemplate()
101103
Unloaded -= OnUnloaded;
102104
Unloaded += OnUnloaded;
103105
}
106+
private void UpdateClearColor()
107+
{
108+
if (canvas == null)
109+
return;
104110

111+
canvas.ClearColor = ClearColor;
112+
}
105113
private void OnUnloaded(object sender, RoutedEventArgs e)
106114
{
107115
if (canvas == null)

0 commit comments

Comments
 (0)