Skip to content

ColorPickerButton SelectedColor binding not updating correctly #4367

@Marv51

Description

@Marv51

Describe the bug

ColorPickerButton's SelectedColor property, ignores changes to the source color completely. The color picker never reflects the updated color, even after it is closed and opened.

From looking at the source ColorPickerButton does not seem to forward changes of the "SelectedColor" to the internal ColorPicker. This is because the Color gets set once during OnApplyTemplate and not afterwards.

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:
    unclear, but clearly a bug

Steps to Reproduce

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)
    Sample App does not cover this use case.

Steps to reproduce the behavior:

<controls:ColorPickerButton  
    SelectedColor="{Binding SelectedElement.ZoneColor, Mode=TwoWay}" />
  • Let's assume SelectedElement.ZoneColor is blue, if you open the color picker, this works correctly.
  • Now close the color picker and through some other method (for example a button) change the SelectedElement.ZoneColor
  • now look at the ColorPickerButton, the preview has updated to the current/correct color
  • Click the ColorPickerButton the colorpicker is still showing the previous blue color as selected

Expected behavior

Screenshots

The source has a blue/cyan color, preview on ColorPickerButton was updated, but colorpicker shows previous value:
grafik

Environment

NuGet Package(s):

Package Version(s): 7.0.3

Windows 10 Build Number:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Win 11 (22000)
  • Insider Build ({build_number})

App min and target version:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • [min] October 2018 Update (17763)
  • May 2019 Update (18362)
  • [target] May 2020 Update (19041)
  • Insider Build ({build_number})

Device form factor:

  • Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio version:

  • 2017 (15.{minor_version})
  • 2019 (16.{minor_version})
  • 2022 (17.{minor_version})

Additional context

Using WinUI 3 Desktop version 0.8.5.

Would a PropertyChangedCallback on the SelectedColor dependency property be the preferred way to fix this? If so I could create a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions