Skip to content

ColorPicker value preview issue within Dialog content #58

@nogiszd

Description

@nogiszd

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:

  1. Insert new ColorPicker control in any Dialog content.
  2. Click on the field to show dropdown.
  3. Select any desired color.
  4. 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.

Image Image

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions