Skip to content

ColorPicker incompatible with AOT #615

Closed
1 of 1 issue completed
Closed

Description

@Marv51

Describe the bug

I'm trying to enable NativeAOT compilation for my app.
I am using Community Toolkit 8.2 Preview 2 (with CsWinRT 2.2) in WinAppSDK/WinUI 1.6.4 on .NET 9.0.1

With AOT enabled, when I click on a ColorPickerButton, which should show a ColorPicker my app crashes with a NotSupportedException. It works perfectly without AOT.

'ICustomProperty support used by XAML binding for type 'CommunityToolkit.WinUI.Controls.SegmentedItem' (property 'Name') requires the type to marked with 'WinRT.GeneratedBindableCustomPropertyAttribute'. If this is a built-in type or a type that can't be marked, a wrapper type should be used around it that is marked to enable this support.'

Steps to reproduce

My colorpickerbutton looks like this:

<!--  xmlns:controls="using:CommunityToolkit.WinUI.Controls"  --->
<controls:ColorPickerButton Background="#818181"
            HorizontalAlignment="Stretch"
            SelectedColor="{x:Bind myObject.Color, Mode=TwoWay}">
</controls:ColorPickerButton>

Expected behavior

No exception

Screenshots

Can provide if required.

Code Platform

  • UWP
  • 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

Windows 11 24H2 (Build 26100)

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

Windows 11, version Build 22621

Visual Studio Version

2022

Visual Studio Build Number

Version 17.12.4

Device form factor

Desktop

Additional context

I believe this Binding in ColorPicker might be at fault:

Value="{Binding ElementName=ColorPanelSelector, Path=SelectedItem.Name}">

And I can indeed, like the exception says, not find any GeneratedBindableCustomProperty attribute on SegmentedItem.

Help us help you

No, I'm unable to contribute a solution.

Activity

  1. added this to the 8.2 milestone on Jan 30, 2025
  2. michael-hawker commented on Feb 3, 2025

    @michael-hawker
    Member

    Related, if not duplicate of #509

  3. moved this to 🆕 New in Toolkit 8.xon Feb 6, 2025
  4. hexawyz commented on May 11, 2025

    @hexawyz

    Hey,

    I stumbled on the same bug when trying to make my app AOT compatible.
    Basically, I ended up in a state where everything I used seems to be working except for the ColorPicker.

    It may not be the best solution, but it seems like "just" annotating SegmentedItem with GeneratedBindableCustomPropertyAttribute as the error suggest might be enough to make things work.
    Sure, it would'nt be the most efficient or optimal way to proceed, but if it works, it can always be improved later.

  5. added
    components::controls::colorpickerAn extended color picker that enables picking a color using a spectrum, sliders, or text input.
    bugSomething isn't working
    on Aug 7, 2025
  6. modified the milestones: 8.2, 8.3 on Aug 26, 2025
  7. moved this from 🆕 New to ✅ Done in Toolkit 8.xon Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponents::controls::colorpickerAn extended color picker that enables picking a color using a spectrum, sliders, or text input.nativeaotThe dependency on dotnet NativeAOT

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions