Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectedColor binding doesn't get updated #29

Closed
Sennevds opened this issue Dec 26, 2019 · 3 comments
Closed

SelectedColor binding doesn't get updated #29

Sennevds opened this issue Dec 26, 2019 · 3 comments
Assignees

Comments

@Sennevds
Copy link

I'm trying to use this nuget package but I've got a problem with the ColorWheel.
When the initial value of the SelectedColor is black(Color.FromHex("#FF000000")) and I use the the colorpicker to set a new value my property in the viewmodel isn't updated.
When I first set my property to another color and then update via the colorwheel my setter is triggerd
Viewmodel property:

   public Color EditedColor1
        {
            get { return _editedColor1; }
            set
            {
                _editedColor1 = value;
                Settings.AddOrUpdateValue("color1", _editedColor1.ToHex());
                RaisePropertyChanged(() => EditedColor1);
                ColorChanged(1);
            }
        }

View

<colorPicker1:ColorWheel Grid.Row="2" Grid.Column="0" x:Name="ColorWheel1" VerticalOptions="FillAndExpand"
                                    ShowAlphaSlider="False"
                                    ShowLuminositySlider="False"
                                    ShowLuminosityWheel="False" SelectedColor="{Binding EditedColor1, Mode=TwoWay}" PropertyChanged="ColorWheel1_OnPropertyChanged"
                                    />

I didn't use the nuget package itself because I'm using a newer version of Xamarin forms so I downloaded your code updated the package and used that dll.

With the slides the problem doesn't occur.

@vpapenko
Copy link
Owner

vpapenko commented Dec 27, 2019

Hi.
You set black as initial color and use only color circle.
Color circle affects Hue and Saturation, but with Luminosity = 0 (from initial black color) you always end up with black color.
If you want to get a saturated color, as you can see in the color circle, you need Luminosity = 0.5.
May be gray initial color is what you need?
If I understand your problem correctly.
P.S. I will update Nuget dependencies and publish new version.

@vpapenko vpapenko self-assigned this Dec 27, 2019
@Sennevds
Copy link
Author

Okay that seems the problem indeed but maybe you need to change the default value for SelectedColorProperty because if someone will use only your colorpicker and no sliders it wont work

public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create(
           nameof(SelectedColor),
           typeof(Color),
           typeof(IColorPicker),
           Color.Black,
           propertyChanged: new BindableProperty.BindingPropertyChangedDelegate(HandleSelectedColorSet), defaultBindingMode: BindingMode.TwoWay);

And thanks for the control it works really nice!

@vpapenko
Copy link
Owner

Good idea.
I published a new version with the latest Xamarin Forms and gray as default color.
Thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants