Skip to content

ColorPicker doesn't triger color Change event after color change from UI #1631

Closed

Description

@flamaniac

After clicking on UI on new color event doesn't trigger

 ColorPicker.ColorChanged += ColorPicker_ColorChanged;
 private void ColorPicker_ColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
{
  // never triggered 
}

Activity

  1. Mrxx99 commented on Feb 1, 2020

    @Mrxx99
    Contributor

    You are right, it is only triggered if the color property is changed outside of the color picker.

    @Keboo this is because if you change to color in the color picker, first the HsbPropertyChangedCallback is called, which sets _inCallback to true, but the ColorPropertyChangedCallback which fires the ColorChanged event then returns early because of this field beeing true.
    I seem to have overlooked that when making my PR (or something changed in between).
    I can make a PR to fix this and firing the event even if _inCallback istrue (it should not get called multiple times, right?)

  2. flamaniac commented on Feb 1, 2020

    @flamaniac
    Author

    I think multiple times - on every change not on Mouse Up.
    ColorPicker

    I made workaround in my app to have this behavior and it works great.
    I call color getter on MouseMove Event. Mouse Move is called only when Mouse Left button and it suits me :) I am getting live upodate.

    ...
        ColorPicker.MouseMove += ColorPicker_MouseMove;
     }
     // ...
          private void ColorPicker_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
          {
              var items = ColorsList.Items;
              ColorItem item;
              for (int i = 0; i < items.Count; ++i)
              {
                  item = (ColorItem)items[i];
                  if (item.IsSelected)
                  {
                      item.Color = ColorPicker.Color;
                  }
              }
          }
    
  3. Mrxx99 commented on Feb 1, 2020

    @Mrxx99
    Contributor

    If you use binding you can also use the setter of the property bound to the Color property of the ColorPicker (that's how it is done in the Demo App)

  4. Mrxx99 commented on Feb 28, 2020

    @Mrxx99
    Contributor

    @Keboo When I add raising event to every time the hsb value change callback is called the color tool get's very laggy. Do you have any idea how this could be done better? Maybe not using a routed event could improve it?

  5. added a commit that references this issue on Jul 3, 2026
  6. added a commit that references this issue on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions