Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit bfd26b1

Browse files
Merge branch 'main' into SmoothScrollIntoView
2 parents e65181b + 28444e9 commit bfd26b1

4 files changed

Lines changed: 35 additions & 30 deletions

File tree

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Windows.UI.Xaml.Controls.Primitives;
1616
using Windows.UI.Xaml.Media;
1717
using ColorPickerSlider = Microsoft.Toolkit.Uwp.UI.Controls.Primitives.ColorPickerSlider;
18+
using ColorSpectrum = Microsoft.UI.Xaml.Controls.Primitives.ColorSpectrum;
1819

1920
namespace Microsoft.Toolkit.Uwp.UI.Controls
2021
{
@@ -52,7 +53,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
5253
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501:Statement should not be on a single line", Justification = "Inline brackets are used to improve code readability with repeated null checks.")]
5354
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1025:Code should not contain multiple whitespace in a row", Justification = "Whitespace is used to align code in columns for readability.")]
5455
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1306:Field names should begin with lower-case letter", Justification = "Only template parts start with a capital letter. This differentiates them from other fields.")]
55-
public partial class ColorPicker : Windows.UI.Xaml.Controls.ColorPicker
56+
public partial class ColorPicker : Microsoft.UI.Xaml.Controls.ColorPicker
5657
{
5758
internal Color CheckerBackgroundColor { get; set; } = Color.FromArgb(0x19, 0x80, 0x80, 0x80); // Overridden later
5859

@@ -122,6 +123,7 @@ public partial class ColorPicker : Windows.UI.Xaml.Controls.ColorPicker
122123
public ColorPicker()
123124
{
124125
this.DefaultStyleKey = typeof(ColorPicker);
126+
this.DefaultStyleResourceUri = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Input/Themes/Generic.xaml");
125127

126128
// Setup collections
127129
this.SetValue(CustomPaletteColorsProperty, new ObservableCollection<Color>());
@@ -486,22 +488,22 @@ private ColorChannel GetActiveColorSpectrumThirdDimension()
486488
{
487489
switch (this.ColorSpectrumComponents)
488490
{
489-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.SaturationValue:
490-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.ValueSaturation:
491+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.SaturationValue:
492+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.ValueSaturation:
491493
{
492494
// Hue
493495
return ColorChannel.Channel1;
494496
}
495497

496-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.HueValue:
497-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.ValueHue:
498+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.HueValue:
499+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.ValueHue:
498500
{
499501
// Saturation
500502
return ColorChannel.Channel2;
501503
}
502504

503-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.HueSaturation:
504-
case Windows.UI.Xaml.Controls.ColorSpectrumComponents.SaturationHue:
505+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.HueSaturation:
506+
case Microsoft.UI.Xaml.Controls.ColorSpectrumComponents.SaturationHue:
505507
{
506508
// Value
507509
return ColorChannel.Channel3;
@@ -1125,7 +1127,7 @@ private void DispatcherQueueTimer_Tick(object sender, object e)
11251127
***************************************************************************************/
11261128

11271129
/// <summary>
1128-
/// Callback for when the <see cref="Windows.UI.Xaml.Controls.ColorPicker.Color"/> dependency property value changes.
1130+
/// Callback for when the <see cref="Microsoft.UI.Xaml.Controls.ColorPicker.Color"/> dependency property value changes.
11291131
/// </summary>
11301132
private void OnColorChanged(DependencyObject d, DependencyProperty e)
11311133
{
@@ -1226,7 +1228,7 @@ private void CustomPaletteColors_CollectionChanged(object sender, NotifyCollecti
12261228
/// Event handler for when the color spectrum color is changed.
12271229
/// This occurs when the user presses on the spectrum to select a new color.
12281230
/// </summary>
1229-
private void ColorSpectrum_ColorChanged(ColorSpectrum sender, Windows.UI.Xaml.Controls.ColorChangedEventArgs args)
1231+
private void ColorSpectrum_ColorChanged(ColorSpectrum sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
12301232
{
12311233
// It is OK in this case to use the RGB representation
12321234
this.ScheduleColorUpdate(this.ColorSpectrumControl.Color);

Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.xaml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
55
xmlns:localconverters="using:Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters"
66
xmlns:primitives="using:Microsoft.Toolkit.Uwp.UI.Controls.Primitives"
7-
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI">
7+
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
8+
xmlns:winuiprimitives="using:Microsoft.UI.Xaml.Controls.Primitives">
89

910
<SolidColorBrush x:Key="CheckerboardColor0">
1011
<SolidColorBrush.Color>
@@ -120,23 +121,23 @@
120121
Orientation="Vertical" />
121122
<!-- Keep in mind the spectrum is always HSV -->
122123
<!-- This must also not be named 'ColorSpectrum' to differentiate from the base class -->
123-
<ColorSpectrum x:Name="ColorSpectrumControl"
124-
Grid.Row="0"
125-
Grid.RowSpan="2"
126-
Grid.Column="1"
127-
MinWidth="256"
128-
MinHeight="256"
129-
HorizontalAlignment="Stretch"
130-
VerticalAlignment="Stretch"
131-
AutomationProperties.Name="Third Dimension"
132-
Components="{TemplateBinding ColorSpectrumComponents}"
133-
MaxHue="{TemplateBinding MaxHue}"
134-
MaxSaturation="{TemplateBinding MaxSaturation}"
135-
MaxValue="{TemplateBinding MaxValue}"
136-
MinHue="{TemplateBinding MinHue}"
137-
MinSaturation="{TemplateBinding MinSaturation}"
138-
MinValue="{TemplateBinding MinValue}"
139-
Shape="{TemplateBinding ColorSpectrumShape}" />
124+
<winuiprimitives:ColorSpectrum x:Name="ColorSpectrumControl"
125+
Grid.Row="0"
126+
Grid.RowSpan="2"
127+
Grid.Column="1"
128+
MinWidth="256"
129+
MinHeight="256"
130+
HorizontalAlignment="Stretch"
131+
VerticalAlignment="Stretch"
132+
AutomationProperties.Name="Third Dimension"
133+
Components="{TemplateBinding ColorSpectrumComponents}"
134+
MaxHue="{TemplateBinding MaxHue}"
135+
MaxSaturation="{TemplateBinding MaxSaturation}"
136+
MaxValue="{TemplateBinding MaxValue}"
137+
MinHue="{TemplateBinding MinHue}"
138+
MinSaturation="{TemplateBinding MinSaturation}"
139+
MinValue="{TemplateBinding MinValue}"
140+
Shape="{TemplateBinding ColorSpectrumShape}" />
140141
<primitives:ColorPickerSlider x:Name="ColorSpectrumAlphaSlider"
141142
Grid.Row="1"
142143
Grid.RowSpan="2"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected override void OnApplyTemplate()
142142
}
143143
}
144144

145-
private void ColorPicker_ColorChanged(Windows.UI.Xaml.Controls.ColorPicker sender, ColorChangedEventArgs args)
145+
private void ColorPicker_ColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
146146
{
147147
SelectedColor = args.NewColor;
148148
}

Microsoft.Toolkit.Uwp.UI.Controls.Primitives/StaggeredLayout/StaggeredLayout.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@ protected override Size MeasureOverride(VirtualizingLayoutContext context, Size
147147
double availableWidth = availableSize.Width;
148148
double availableHeight = availableSize.Height;
149149

150-
double columnWidth = Math.Min(DesiredColumnWidth, availableWidth);
150+
// This ternary prevents the column width from being NaN, which would otherwise cause an exception when measuring item sizes
151+
double columnWidth = double.IsNaN(DesiredColumnWidth) ? availableWidth : Math.Min(DesiredColumnWidth, availableWidth);
151152
if (columnWidth != state.ColumnWidth)
152153
{
153154
// The items will need to be remeasured
154155
state.Clear();
155156
}
156157

157-
state.ColumnWidth = Math.Min(DesiredColumnWidth, availableWidth);
158+
// This ternary prevents the column width from being NaN, which would otherwise cause an exception when measuring item sizes
159+
state.ColumnWidth = double.IsNaN(DesiredColumnWidth) ? availableWidth : Math.Min(DesiredColumnWidth, availableWidth);
158160
int numColumns = Math.Max(1, (int)Math.Floor(availableWidth / state.ColumnWidth));
159161

160162
// adjust for column spacing on all columns expect the first

0 commit comments

Comments
 (0)