diff --git a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs index 3c38c6ed1b..78a796e93a 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs @@ -332,6 +332,20 @@ namespace Avalonia.Controls.Primitives disableUpdates = false; } + else if (change.Property == ColorModelProperty) + { + disableUpdates = true; + + if (IsAutoUpdatingEnabled) + { + SetColorToSliderValues(); + UpdateBackground(); + } + + UpdatePseudoClasses(); + + disableUpdates = false; + } else if (change.Property == HsvColorProperty) { disableUpdates = true; diff --git a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs index eddbeaf112..c56811b8a3 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.Properties.cs @@ -7,7 +7,6 @@ namespace Avalonia.Controls { public partial class ColorView { - // SelectedColorModel ActiveColorModel? // SelectedTab /// @@ -19,6 +18,14 @@ namespace Avalonia.Controls Colors.White, defaultBindingMode: BindingMode.TwoWay); + /// + /// Defines the property. + /// + public static readonly StyledProperty ColorModelProperty = + AvaloniaProperty.Register( + nameof(ColorModel), + ColorModel.Rgba); + /// /// Defines the property. /// @@ -203,6 +210,17 @@ namespace Avalonia.Controls set => SetValue(ColorProperty, value); } + /// + /// + /// This property is only applicable to the components tab. + /// The spectrum tab must always be in HSV and the palette tab is pre-defined colors. + /// + public ColorModel ColorModel + { + get => GetValue(ColorModelProperty); + set => SetValue(ColorModelProperty, value); + } + /// public ColorSpectrumComponents ColorSpectrumComponents { diff --git a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml index 5d3642a3b1..b037d14956 100644 --- a/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml +++ b/src/Avalonia.Controls.ColorPicker/Themes/Fluent/ColorView.xaml @@ -1,5 +1,6 @@  + @@ -156,6 +158,11 @@ + + + + + + + + + + + + + + + + + + + + Grid.Column="2"> @@ -260,12 +333,17 @@ BorderThickness="1,1,0,1" CornerRadius="4,0,0,4" VerticalAlignment="Center"> - + + + + - + + + + - + + + +