Skip to content

Commit 2b124ff

Browse files
Merge pull request #3943 from robloo/color-picker-prop-fix
Fix ColorPicker CustomPaletteColors default property value
2 parents 487bc4d + e86bfee commit 2b124ff

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.Properties.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public partial class ColorPicker
2020
nameof(CustomPaletteColors),
2121
typeof(ObservableCollection<Windows.UI.Color>),
2222
typeof(ColorPicker),
23-
new PropertyMetadata(Windows.UI.Color.FromArgb(0x00, 0x00, 0x00, 0x00)));
23+
new PropertyMetadata(null));
2424

2525
/// <summary>
2626
/// Gets the list of custom palette colors.
@@ -64,7 +64,7 @@ public int CustomPaletteColumnCount
6464
nameof(CustomPalette),
6565
typeof(IColorPalette),
6666
typeof(ColorPicker),
67-
new PropertyMetadata(DependencyProperty.UnsetValue));
67+
new PropertyMetadata(null));
6868

6969
/// <summary>
7070
/// Gets or sets the custom color palette.

Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorToColorShadeConverter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using Microsoft.Toolkit.Uwp.Helpers;
77
using Windows.UI;
8+
using Windows.UI.Xaml;
89
using Windows.UI.Xaml.Data;
910
using Windows.UI.Xaml.Media;
1011

@@ -40,7 +41,8 @@ public object Convert(
4041
}
4142
else
4243
{
43-
throw new ArgumentException("Invalid color value provided");
44+
// Invalid color value provided
45+
return DependencyProperty.UnsetValue;
4446
}
4547

4648
// Get the value component delta
@@ -50,7 +52,8 @@ public object Convert(
5052
}
5153
catch
5254
{
53-
throw new ArgumentException("Invalid parameter provided, unable to convert to integer");
55+
// Invalid parameter provided, unable to convert to integer
56+
return DependencyProperty.UnsetValue;
5457
}
5558

5659
// Specially handle minimum (black) and maximum (white)
@@ -119,7 +122,7 @@ public object ConvertBack(
119122
object parameter,
120123
string language)
121124
{
122-
throw new NotImplementedException();
125+
return DependencyProperty.UnsetValue;
123126
}
124127
}
125128
}

Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorToHexConverter.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using Microsoft.Toolkit.Uwp.Helpers;
77
using Windows.UI;
8+
using Windows.UI.Xaml;
89
using Windows.UI.Xaml.Data;
910
using Windows.UI.Xaml.Media;
1011

@@ -34,7 +35,8 @@ public object Convert(
3435
}
3536
else
3637
{
37-
throw new ArgumentException("Invalid color value provided");
38+
// Invalid color value provided
39+
return DependencyProperty.UnsetValue;
3840
}
3941

4042
string hexColor = color.ToHex().Replace("#", string.Empty);
@@ -58,7 +60,8 @@ public object ConvertBack(
5860
}
5961
catch
6062
{
61-
throw new ArgumentException("Invalid hex color value provided");
63+
// Invalid hex color value provided
64+
return DependencyProperty.UnsetValue;
6265
}
6366
}
6467
else
@@ -69,7 +72,8 @@ public object ConvertBack(
6972
}
7073
catch
7174
{
72-
throw new ArgumentException("Invalid hex color value provided");
75+
// Invalid hex color value provided
76+
return DependencyProperty.UnsetValue;
7377
}
7478
}
7579
}

Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ContrastBrushConverter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using Windows.UI;
7+
using Windows.UI.Xaml;
78
using Windows.UI.Xaml.Data;
89
using Windows.UI.Xaml.Media;
910

@@ -40,7 +41,8 @@ public object Convert(
4041
}
4142
else
4243
{
43-
throw new ArgumentException("Invalid color value provided");
44+
// Invalid color value provided
45+
return DependencyProperty.UnsetValue;
4446
}
4547

4648
// Get the default color when transparency is high
@@ -81,7 +83,7 @@ public object ConvertBack(
8183
object parameter,
8284
string language)
8385
{
84-
throw new NotImplementedException();
86+
return DependencyProperty.UnsetValue;
8587
}
8688

8789
/// <summary>

Microsoft.Toolkit.Uwp.UI/Converters/ColorToDisplayNameConverter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using Windows.UI;
7+
using Windows.UI.Xaml;
78
using Windows.UI.Xaml.Data;
89
using Windows.UI.Xaml.Media;
910

@@ -33,7 +34,8 @@ public object Convert(
3334
}
3435
else
3536
{
36-
throw new ArgumentException("Invalid color value provided");
37+
// Invalid color value provided
38+
return DependencyProperty.UnsetValue;
3739
}
3840

3941
return ColorHelper.ToDisplayName(color);
@@ -46,7 +48,7 @@ public object ConvertBack(
4648
object parameter,
4749
string language)
4850
{
49-
throw new NotImplementedException();
51+
return DependencyProperty.UnsetValue;
5052
}
5153
}
5254
}

0 commit comments

Comments
 (0)