Browse Source

Fixed Color Property color picker not working

CPKreuz 1 year ago
parent
commit
7c560c0fd5

+ 8 - 1
src/PixiEditor.AvaloniaUI/ViewModels/Nodes/Properties/ColorPropertyViewModel.cs

@@ -1,4 +1,5 @@
-using PixiEditor.DrawingApi.Core.ColorsImpl;
+using PixiEditor.AvaloniaUI.Helpers.Extensions;
+using PixiEditor.DrawingApi.Core.ColorsImpl;
 
 namespace PixiEditor.AvaloniaUI.ViewModels.Nodes.Properties;
 
@@ -7,4 +8,10 @@ internal class ColorPropertyViewModel : NodePropertyViewModel<Color>
     public ColorPropertyViewModel(NodeViewModel node, Type valueType) : base(node, valueType)
     {
     }
+
+    public new Avalonia.Media.Color Value
+    {
+        get => base.Value.ToColor();
+        set => base.Value = value.ToColor();
+    }
 }

+ 5 - 1
src/PixiEditor.AvaloniaUI/Views/Nodes/Properties/ColorPropertyView.axaml

@@ -11,6 +11,10 @@
                              x:Class="PixiEditor.AvaloniaUI.Views.Nodes.Properties.ColorPropertyView">
     <Grid HorizontalAlignment="{Binding IsInput, Converter={converters:BoolToValueConverter FalseValue='Right', TrueValue='Stretch'}}">
         <TextBlock VerticalAlignment="Center" ui:Translator.Key="{Binding DisplayName}"/>
-        <colorPicker:PortableColorPicker PointerPressed="InputElement_OnPointerPressed" Width="40" Height="20" IsVisible="{Binding IsInput}" SelectedColor="{Binding Value, Mode=TwoWay}" />
+        <colorPicker:PortableColorPicker
+            PointerPressed="InputElement_OnPointerPressed"
+            Width="40" Height="20"
+            IsVisible="{Binding IsInput}"
+            SelectedColor="{Binding Value, Mode=TwoWay}" />
     </Grid>
 </properties:NodePropertyView>