<colorPicker:ColorPicker x:Name="main"
Grid.ColumnSpan="2"
Margin="10"
Color="{Binding CurrentColor, Mode=TwoWay}">
<colorPicker:ColorPicker.Styles>
<Style Selector="colorPicker|ColorPicker /template/ colorPicker|ColorPickerValuesPresenter">
<Setter Property="MinHeight" Value="200" />
<Setter Property="MinWidth" Value="200" />
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="colorPicker|ColorPicker /template/ colorPicker|ColorPickerPropertiesPresenter#PART_ColorPickerPropertiesPresenter">
<Setter Property="(DockPanel.Dock)" Value="Right" />
<Setter Property="IsVisible" Value="False" />
</Style>
</colorPicker:ColorPicker.Styles>
</colorPicker:ColorPicker>
Everything is working fine, the two way binding is updating correctly. CurrentColor
is of Type Avalonia.Media.Color
.
The issue manifests when the color selector is dragged to the extreme bottom edge. Which errors here:
private static bool ValidateValue(double value)
{
if (value < 0.0 || value > 100.0)
{
throw new ArgumentException("Invalid Value value.");
}
return true;
}
With the following stack trace.
System.ArgumentException: Invalid Value value.
at ThemeEditor.Controls.ColorPicker.Props.HsvProperties.ValidateValue(Double value) in /_/src/ThemeEditor.Controls.ColorPicker/Props/HsvProperties.cs:line 54
at Avalonia.ValueStore.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 98
at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 367
at ThemeEditor.Controls.ColorPicker.Props.HsvProperties.set_Value(Double value) in /_/src/ThemeEditor.Controls.ColorPicker/Props/HsvProperties.cs:line 83
at ThemeEditor.Controls.ColorPicker.Props.HsvProperties.UpdatePropertyValues() in /_/src/ThemeEditor.Controls.ColorPicker/Props/HsvProperties.cs:line 105
at ThemeEditor.Controls.ColorPicker.ColorPickerProperties.<OnColorPickerChange>b__12_2(Double _) in /_/src/ThemeEditor.Controls.ColorPicker/ColorPickerProperties.cs:line 55
at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 34
at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value) in /_/src/Avalonia.Base/Reactive/LightweightObservableBase.cs:line 139
at Avalonia.Reactive.AvaloniaPropertyObservable`1.PropertyChanged(Object sender, AvaloniaPropertyChangedEventArgs e) in /_/src/Avalonia.Base/Reactive/AvaloniaPropertyObservable.cs:line 67
at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 761
at Avalonia.AvaloniaObject.Avalonia.PropertyStore.IValueSink.ValueChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 531
at Avalonia.ValueStore.NotifyValueChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 355
at Avalonia.ValueStore.SetExisting[T](Object slot, StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 284
at Avalonia.ValueStore.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 107
at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase`1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 367
at ThemeEditor.Controls.ColorPicker.ColorPickerValuesPresenter.set_Value3(Double value) in /_/src/ThemeEditor.Controls.ColorPicker/ColorPickerValuesPresenter.cs:line 56
at ThemeEditor.Controls.ColorPicker.ColorPickerValuesPresenter.UpdateValuesFromThumbs() in /_/src/ThemeEditor.Controls.ColorPicker/ColorPickerValuesPresenter.cs:line 220
at ThemeEditor.Controls.ColorPicker.ColorPickerValuesPresenter.ColorCanvas_PointerMoved(Object sender, PointerEventArgs e) in /_/src/ThemeEditor.Controls.ColorPicker/ColorPickerValuesPresenter.cs:line 311
at Avalonia.Interactivity.Interactive.<AddHandler>g__InvokeAdapter|4_0[TEventArgs](Delegate baseHandler, Object sender, RoutedEventArgs args) in /_/src/Avalonia.Interactivity/Interactive.cs:line 62
at Avalonia.Interactivity.Interactive.<>c__4`1.<AddHandler>b__4_1(Delegate baseHandler, Object sender, RoutedEventArgs args) in /_/src/Avalonia.Interactivity/Interactive.cs:line 68
at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 167
at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 101
at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/Interactive.cs:line 122
at Avalonia.Input.MouseDevice.MouseMove(IMouseDevice device, UInt64 timestamp, IInputRoot root, Point p, PointerPointProperties properties, KeyModifiers inputModifiers, Lazy`1 intermediatePoints) in /_/src/Avalonia.Input/MouseDevice.cs:line 292
at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e) in /_/src/Avalonia.Input/MouseDevice.cs:line 182
at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e) in /_/src/Avalonia.Input/MouseDevice.cs:line 90
at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in /_/src/Avalonia.Input/InputManager.cs:line 35
at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in /_/src/Avalonia.Controls/TopLevel.cs:line 504
at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs:line 520
at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs:line 30
at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 210
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 65
at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 209
If I have some time later I'll pull the source into my project and see if I can identify the cause.