1
Vote

SelectedColor doesn't update the visuals when set via binding

description

public Color SelectedColor
    {
        get { return (Color) GetValue(SelectedColorProperty);}
        set
        {
            SetValue(SelectedColorProperty, value);
            //p.UpdateVisuals();     this has to happen in the SelectedColorPropertyChanged
        }
    }
 
private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        ColorPicker p = d as ColorPicker;
        if (p != null && p.SelectedColorChanged != null)
        {
            SelectedColorEventArgs args = new SelectedColorEventArgs((Color) e.NewValue);
            p.SelectedColorChanged(p, args);
        }
        p.UpdateVisuals();    // this is the fix
    }

comments