Windows icon indicating copy to clipboard operation
Windows copied to clipboard

XAML Binding failed in ColorPicker

Open Poker-sang opened this issue 9 months ago • 0 comments

Describe the bug

The ColorPicker/ColorPickerButton has a binding failed issue (When use {x:Bind} on ColorPicker.Color or ColorPickerButton.SelectedColor):

CommunityToolkit.WinUI.Controls.ColorPicker
Color
Microsoft.UI.Xaml.Controls.GridView.SelectedValue
Object
Converter failed to convert value of type 'null' to type 'Color'			

This issue has been present since version 7.x.

Steps to reproduce

It's easy to reproduce this issue:

<controls:ColorPicker Color="{x:Bind ColorX}" />
Color ColorX { get; set; }

And then you can see: (see Screenshots)

Expected behavior

No Binding failure

Screenshots

image

image

Code Platform

  • [ ] UWP
  • [X] WinAppSDK / WinUI 3
  • [ ] Web Assembly (WASM)
  • [ ] Android
  • [ ] iOS
  • [ ] MacOS
  • [ ] Linux / GTK

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 10 21H2 (Build 19044)
  • [ ] Windows 10 22H2 (Build 19045)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Windows 10, version 2104 (Build 20348)
  • [ ] Windows 11, version 22H2 (Build 22000)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

I thought the bug is caused by this line:

https://github.com/CommunityToolkit/Windows/blob/967d6c453615e0e2f9de56c2976ccfc6cc9c0008/components/ColorPicker/src/ColorPicker.xaml#L294

Maybe the TemplateParent is null or something?

Help us help you

No, I'm unable to contribute a solution.

Poker-sang avatar May 06 '24 08:05 Poker-sang