Closed berruezo closed 1 year ago
@robloo might know more about it
So the ColorPicker derives from ColorView but also has the ColorView in the control template. This means there are two instances of the ColorView in existence. The ignorePropertyChanges is set to true for the ColorPicker because it doesnt need to do anything -- everything should be handled in the ColorView. We don't want logic fighting each other.
All properties are two-way bound so when you change Color on ColorPicker that is bound to and updates the Color property on ColorView hosted in the control template. Then when Color changes, HsvColor is updated and all changes propagate back to ColorPicker.
Anyway, just some background. It's interesting this isn't working and I'll take a look. Hope it isn't another lifecyle issue because the ColorView isn't created yet...
Thanks for the background you gave. Makes sense to me. But you may be right about the lifecycle thing.
This is caused by the same lifecycle issue I've seen before. I'm hitting problems with lazy-loading Popup/Flyout in control templates. I don't ever recall running into this problem with WinUI.
In this case the following happens:
"Works (kind-of)":
HsvColor
on the ColorPickerDoes NOT Work:
Color
on the ColorPicker@maxkatz6 What do I need to do to allow popups/flyouts in control template to be loaded with the rest of the control template? I think this is how it should work by default. Seems like a deep change but absolutely necessary IMO.
I have a fix for this that is the lesser of two evils. It will be included with #9140.
What it does is switch the main processing from the ColorView
hosted in the control template to the ColorPicker
itself. This works-around lifetime limitations with how the control is created (and the template applied, I got lazy trying to make the control as simple as possible and overlooked this). As a side-effect, a new property for IsHostedInColorPicker
is added -- that's the lesser of two evils. I normally don't like properties like this but the alternative was to attempt to pass control back-and-forth between the ColorPicker
and ColorView
based on when the template is applied. That is potentially error-prone and is likely difficult to maintain.
Also see the discussion here: https://github.com/AvaloniaUI/Avalonia/discussions/9128
Describe the bug When modifying the
Color
property manually, the color of theColorPicker
doesn't change However, when modifying theHsvColor
property, the color changes correctlyI found in the xml that the
ColorPicker
uses theHsvColor
property to draw itsBackground
. This property should automatically change when theColor
property changes, but this is not happening because theignorePropertyChanged
is set to true for theColorPicker
To Reproduce Create a
ColorPicker
and change itsColor
Expected behavior The color of the
ColorPicker
(and theColorView
popup) should changeDesktop (please complete the following information):