You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the CustomPalette property of ColorPicker is explicitly assigned in the code, it prevents the property to be styled.
Style setters will always have les priority than directly assigned values, with the assumption that those values come from the final user. In this case, the FluentPalette assigned would override any style defined, as it is assigned in the same way user code would do.
This issue can be worked around by listening for the Loaded event and manually overriding the property there, however, in addidition to defeating the purpose of dependency properties, it is not convenient, and can lead to issues. (e.g. in the case of a ColorPickerButton, the ColorPicker can sometimes be null when the event handler is called. From what I understand this would occur if the component is initally Visibility.Collapsed)
Steps to reproduce
In an empty project:
1. Create an implementation of IColorPalette (For example: https://github.com/hexawyz/Exo/blob/master/Exo.Settings.Ui/RgbLightingDefaultPalette.cs)
2. Add a new `ColorPickerStyle` in `App.xaml`
3. Add a ColorPicker in your main page, using the style defined in your app.xaml
4. Run the application, and observe the custom palette displayed by `ColorPicker`
The custom color palette should be used in the ColorPicker on which the custom style has been applied, instead of the FluentColorPalette.
Screenshots
The ColorPicker in the background has the custom style applied and does not display the custom palette.
The ColorPicker in front has the CustomPalette property manually assigned and correctly displays the custom palette.
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
2022, Preview
Visual Studio Build Number
No response
Device form factor
Desktop
Additional context
I've hastily put up an example of how this could be fixed here: hexawyz@b7c74e9
I assume this is enough, but a better fix would likely be to assign the CustomPalette within the DefaultColorPickerStyle only.
Describe the bug
Because the
CustomPalette
property ofColorPicker
is explicitly assigned in the code, it prevents the property to be styled.Style setters will always have les priority than directly assigned values, with the assumption that those values come from the final user. In this case, the FluentPalette assigned would override any style defined, as it is assigned in the same way user code would do.
This issue can be worked around by listening for the
Loaded
event and manually overriding the property there, however, in addidition to defeating the purpose of dependency properties, it is not convenient, and can lead to issues. (e.g. in the case of a ColorPickerButton, the ColorPicker can sometimes be null when the event handler is called. From what I understand this would occur if the component is initallyVisibility.Collapsed
)Steps to reproduce
With the color palette example linked above:
App.xaml:
MainWindow.xaml:
Expected behavior
The custom color palette should be used in the
ColorPicker
on which the custom style has been applied, instead of theFluentColorPalette
.Screenshots
The
ColorPicker
in the background has the custom style applied and does not display the custom palette.The
ColorPicker
in front has theCustomPalette
property manually assigned and correctly displays the custom palette.Code Platform
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022, Preview
Visual Studio Build Number
No response
Device form factor
Desktop
Additional context
I've hastily put up an example of how this could be fixed here: hexawyz@b7c74e9
I assume this is enough, but a better fix would likely be to assign the
CustomPalette
within theDefaultColorPickerStyle
only.NB: This problem has been present for a long time and was already existing in the original repo: https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/main/Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPicker.cs#L1062
AFAIK, it is not dependent on the version of Windows or of the SDK, so you should ingore those informations.
Help us help you
Yes, I'd like to be assigned to work on this item.
The text was updated successfully, but these errors were encountered: