-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Describe the bug
I'm not sure if this is a bug in AvaloniaUI (since I couldn’t find any similar reports), but when the ColorPicker component is placed inside a UserControl that represents a dialog's UI, its text value does not update when the bound color changes.
Only the Border element - which has its Background bound to the same value - updates correctly.
To Reproduce
Steps to reproduce the behavior:
- Insert new
ColorPickercontrol in anyDialogcontent. - Click on the field to show dropdown.
- Select any desired color.
- See that text value of preview doesn't change, but value itself is changing inside of
ViewModel.
Expected behavior
Expected behavior is to make both controls in StackPanel react to changes of property that was bound to ColorPicker's Color property. For now, text value is always stuck in default assigned value, and only Border changes background color.
Screenshots
If applicable, add screenshots to help explain your problem.
Below are screenshots from DeveloperTools that show exactly which properties are updated and which are not.
Desktop (please complete the following information):
- OS: Microsoft Windows
- Version 11 (24H2)
Additional context
For anyone that happens to stumble upon same problem, only fix I've come up with, without tinkering in library code is to replace default Content of ColorPicker:
<ColorPicker Color="{Binding SelectedColor, Converter={x:Static converters:StringToColor.Instance}, Mode=TwoWay}" shad:ControlAssist.Label="Choose a color">
<ColorPicker.Content>
<StackPanel Orientation="Horizontal" Spacing="6" HorizontalAlignment="Stretch">
<Border Width="20" Height="20"
Background="{Binding SelectedColor}"
CornerRadius="{DynamicResource SmCornerRadius}" />
<TextBlock Text="{Binding SelectedColor}" />
</StackPanel>
</ColorPicker.Content>
</ColorPicker>