Closed
Labels
bugSomething isn't workingSomething isn't workingcomponents::controls::colorpickerAn extended color picker that enables picking a color using a spectrum, sliders, or text input.An extended color picker that enables picking a color using a spectrum, sliders, or text input.nativeaotThe dependency on dotnet NativeAOTThe dependency on dotnet NativeAOTregressionWhat was working is now brokeWhat was working is now brokesample app 🖼️
Description
Describe the bug
When running the gallery with the Wasdk head on the latest main commit, the ColorPicker sample will crash the app:
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(IObjectReference _obj, Size availableSize)
at Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size availableSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)
This crash does not occur under UWP.
Steps to reproduce
1. Clone the repo
2. Generate the gallery solution, include the ColorPicker component and the wasdk multitarget/head.
3. Build and deploy the wasdk gallery
4. Navigate to the ColorPicker sample page and observe crash.
Expected behavior
No crash.
Screenshots
No response
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
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
No response
Help us help you
Yes, I'd like to be assigned to work on this item.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcomponents::controls::colorpickerAn extended color picker that enables picking a color using a spectrum, sliders, or text input.An extended color picker that enables picking a color using a spectrum, sliders, or text input.nativeaotThe dependency on dotnet NativeAOTThe dependency on dotnet NativeAOTregressionWhat was working is now brokeWhat was working is now brokesample app 🖼️
Type
Projects
- StatusShow more project fields✅ Done

Activity
Arlodotexe commentedon Sep 18, 2024
Has the same error message as #517
Arlodotexe commentedon Sep 18, 2024
Additional info uncovered thanks to a tip from @Sergio0694
(Possibly related to #516? Though, not the same error message.)
@michael-hawker Anything you could add? SwitchPresenter may be having more than one AoT issue here.
michael-hawker commentedon Sep 18, 2024
@Arlodotexe Switch Presenter uses all the general types and such from XAML like
DependencyObjectCollectionandDependencyObject- It also just does a lot of general comparison/reflection-y type stuff when trying to compare values here: https://github.com/CommunityToolkit/Windows/blob/main/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs#L116So, there's probably something there to figure out how to better guard against?
I also saw a new issue on the WinUI repo about controls and resource dictionaries + trimming, so something we may want to keep an eye on incase there's other underlying issues still we need to be concerned about or bubble up with the platform team. RE: microsoft/microsoft-ui-xaml#10020
Arlodotexe commentedon Oct 17, 2024
Since #516 turned out to be an issue with the EnumValuesExtension, I suspect this may be a binding issue given the data in the exception. Could also be erroring internally in the setter, but the
Valueproperty is a good place to start looking.Arlodotexe commentedon Nov 4, 2024
It looks like the problem is here:
Windows/components/ColorPicker/src/ColorPicker.xaml
Lines 238 to 240 in 7ab8a42
Unfortunately, this isn't a backed resource dictionary, so we can't use
x:Bindhere. If we try, we get the error:To fix the problem, we'll need to locate any
.xamlfiles that use a non-TemplatedParentvariant of{Binding}, update the resource dictionary to be backed by acsfile, and update bindings to usex:Bind.michael-hawker commentedon Dec 6, 2024
This issue got opened on the WinUI repo which is related microsoft/microsoft-ui-xaml#10214 - not too sure what we can do here atm.
AndrewKeepCoding commentedon Jul 17, 2025
The
SwitchPresenteronly needs the Name of the selected item from theSegmentedcontrol. Since thisSegementedcontrol is already accessible as aTemplatedPart, why not just also include theSwitchPresenteras aTemplatedPartand implement the selection logic in code?That should at least prevent crashes.
AndrewKeepCoding commentedon Jul 17, 2025
Yes, it worked with a few lines of code:
@Arlodotexe @michael-hawker Thoughts?
michael-hawker commentedon Jul 18, 2025
Thanks @AndrewKeepCoding, I suppose that could work for now; we could add a comment pointing to the WinUI issue: microsoft/microsoft-ui-xaml#10214
AndrewKeepCoding commentedon Jul 19, 2025
Hi @michael-hawker ! Should I be assigned to create a PR for this? or can I go ahead and create one?