diff --git a/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs b/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs
index 140a24d6a1..d34a91d1bb 100644
--- a/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs
+++ b/src/Avalonia.Controls.ColorPicker/ColorPicker/ColorPicker.cs
@@ -12,5 +12,14 @@ namespace Avalonia.Controls
///
public class ColorPicker : ColorView
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ColorPicker() : base()
+ {
+ // Completely ignore property changes here
+ // The ColorView in the control template is responsible to manage this
+ base.ignorePropertyChanged = true;
+ }
}
}
diff --git a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs
index 957e5e7b77..a9ba5a20fa 100644
--- a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs
+++ b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs
@@ -29,7 +29,7 @@ namespace Avalonia.Controls.Primitives
///
private const double MaxHue = 359;
- private bool disableUpdates = false;
+ protected bool ignorePropertyChanged = false;
///
/// Initializes a new instance of the class.
@@ -135,7 +135,7 @@ namespace Avalonia.Controls.Primitives
///
///
/// Warning: This will trigger property changed updates.
- /// Consider using externally.
+ /// Consider using externally.
///
private void SetColorToSliderValues()
{
@@ -341,7 +341,7 @@ namespace Avalonia.Controls.Primitives
///
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
- if (disableUpdates)
+ if (ignorePropertyChanged)
{
base.OnPropertyChanged(change);
return;
@@ -350,7 +350,7 @@ namespace Avalonia.Controls.Primitives
// Always keep the two color properties in sync
if (change.Property == ColorProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
HsvColor = Color.ToHsv();
@@ -362,21 +362,21 @@ namespace Avalonia.Controls.Primitives
change.GetOldValue(),
change.GetNewValue()));
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
else if (change.Property == ColorModelProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
SetColorToSliderValues();
UpdateBackground();
UpdatePseudoClasses();
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
else if (change.Property == HsvColorProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
Color = HsvColor.ToRgb();
@@ -388,7 +388,7 @@ namespace Avalonia.Controls.Primitives
change.GetOldValue().ToRgb(),
change.GetNewValue().ToRgb()));
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
else if (change.Property == IsRoundingEnabledProperty)
{
@@ -402,7 +402,7 @@ namespace Avalonia.Controls.Primitives
change.Property == MinimumProperty ||
change.Property == MaximumProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
Color oldColor = Color;
(var color, var hsvColor) = GetColorFromSliderValues();
@@ -421,7 +421,7 @@ namespace Avalonia.Controls.Primitives
UpdatePseudoClasses();
OnColorChanged(new ColorChangedEventArgs(oldColor, Color));
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
base.OnPropertyChanged(change);
diff --git a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs
index 96de734cc7..c19daf5f40 100644
--- a/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs
+++ b/src/Avalonia.Controls.ColorPicker/ColorView/ColorView.cs
@@ -27,7 +27,7 @@ namespace Avalonia.Controls
private ObservableCollection _customPaletteColors = new ObservableCollection();
private ColorToHexConverter colorToHexConverter = new ColorToHexConverter();
- private bool disableUpdates = false;
+ protected bool ignorePropertyChanged = false;
///
/// Initializes a new instance of the class.
@@ -167,7 +167,7 @@ namespace Avalonia.Controls
///
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
- if (disableUpdates)
+ if (ignorePropertyChanged)
{
base.OnPropertyChanged(change);
return;
@@ -176,7 +176,7 @@ namespace Avalonia.Controls
// Always keep the two color properties in sync
if (change.Property == ColorProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
HsvColor = Color.ToHsv();
SetColorToHexTextBox();
@@ -185,11 +185,11 @@ namespace Avalonia.Controls
change.GetOldValue(),
change.GetNewValue()));
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
else if (change.Property == HsvColorProperty)
{
- disableUpdates = true;
+ ignorePropertyChanged = true;
Color = HsvColor.ToRgb();
SetColorToHexTextBox();
@@ -198,7 +198,7 @@ namespace Avalonia.Controls
change.GetOldValue().ToRgb(),
change.GetNewValue().ToRgb()));
- disableUpdates = false;
+ ignorePropertyChanged = false;
}
else if (change.Property == CustomPaletteProperty)
{