-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix ColorPicker CustomPaletteColors default property value #3943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ColorPicker CustomPaletteColors default property value #3943
Conversation
|
Thanks robloo for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
|
Hello @Kyaa-dost! Because this pull request has the Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 6 hours 34 minutes. No worries though, I will be back when the time is right! 😉 p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
@msftbot Merge when @michael-hawker approves the PR |
|
Hello @Kyaa-dost! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
| typeof(ObservableCollection<Windows.UI.Color>), | ||
| typeof(ColorPicker), | ||
| new PropertyMetadata(Windows.UI.Color.FromArgb(0x00, 0x00, 0x00, 0x00))); | ||
| new PropertyMetadata(DependencyProperty.UnsetValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never be using UnsetValue here, this should be always be null, if not a method. We should only use UnsetValue for value converters (bug #3311).
See docs for PropertyMetadata and UnsetValue both call this out.
Can you fix this here an in the other places as well? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-hawker Ok, I will update. This was my misunderstanding. It would make sense that the property system supported this case (using default(T) as needed) but if it doesn't, it doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no worries. Sorry we missed it in the initial PR. It's extra confusing because it's the opposite guidance for the Value Converters. We just haven't had a chance to go fix those yet with all the other work we did for 7.0. Thanks a bunch for working through the fix on the issue thread with the original reporter! 🦙❤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed some other occurrences of UnsetValue doing a quick search. Here is an example:
I think the code base needs to be audited for this situation a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the changes and updated the converters I added to return UnsetValue instead of throwing exceptions. I also removed the NotImplementedException from ConvertBack() it wasn't entirely clear if that should change per the docs.
I still can't believe it isn't supported in registration like this. DependencyObject.ReadLocalValue may return UnsetValue. ClearValue() uses it I think? I would also expect the default PropertyMetadata to use UnsetValue instead of null. Oh well, it's good to be aware of this.
|
This PR has been marked as "needs attention 👋" and awaiting a response from the team. |
|
I also switched to the WinUI ColorSpectrum and hit a roadblock. The ColorPicker itself forwards the ColorSpectrumComponents and ColorSpectrumShape properties directly to the internal spectrum. I can't have the ColorPicker using Windows.UI.Xaml enum values but the internal ColorSpectrum using Microsoft.UI.Xaml. Bottom line I need to switch the ColorPicker itself to derive from the WinUI ColorPicker as well. Then we run into microsoft/microsoft-ui-xaml#3502 which normally requires the following line of code
I am unsure if this is safe to do in a library released to Nuget. |
|
@azchohfi did you have to update this for the WinUI changes since those all inherit now? @robloo is the concern about it functioning or just changing things in a minor released version? I believe the WUX and MUX API surfaces are similar, so if we're functionally equivalent, I don't see a large problem with moving things forward? |
I'm concerned about it functioning. I'm not sure how Uri-based resource lookup works with a nuget library packaged with an app. In other words: I'm not sure how resource lookup works internally in this case with WinUI-styles, within the UWP toolkit added as a nuget to an app. Will everything still be packaged and appear normally with ms-appx?. For the minor-breaking change I also wasn't thinking it was a concern. If anyone customizes things that will likely do it in XAML anyway. I considered the breaking change ok but made sure to flag it. |
|
Wondering if we want to split the @robloo thoughts? |
I had a thought you might say that. Agreed and done. See PR #4010 |
## Fixes #
Fixes some potential crashes with the built-in Windows 10 ColorSpectrum by switching to the WinUI version instead with the latest bug fixes.
* ColorPicker and ColorSpectrum now derive from the WinUI equivalent controls
<!-- Add a brief overview here of the feature/bug & fix. -->
## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->
- Bugfix
<!-- - Feature -->
<!-- - Code style update (formatting) -->
- Refactoring (no functional changes, no api changes)
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
## PR Checklist
Please check if your PR fulfills the following requirements:
- [x] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] ~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link:~ <!-- docs PR link -->
- [ ] ~Sample in sample app has been added / updated (for bug fixes / features)~
- [ ] ~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~
- [ ] ~New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...~
- [ ] ~Tests for the changes have been added (for bug fixes / features) (if applicable)~
- [ ] ~Header has been added to all new source files (run *build/UpdateHeaders.bat*)~
- [ ] Contains **NO** breaking changes
**Anyone customizing the Spectrum shape or components directly in C# will need to switch to Microsoft.UI.Xaml namespace**
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->
## Other information
See discussion in #3943 #3943 (comment)
Fixes #3940, Relates to #3311
ColorPicker and ColorSpectrum now derive from the WinUI equivalent controlsAnyone customizing the Spectrum shape or components directly in C# will need to switch to Microsoft.UI.Xaml namespace This is a breaking change in code only - XAML will work unchanged.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Pull Request has been submitted to the documentation repository instructions. Link:Sample in sample app has been added / updated (for bug fixes / features)Icon has been created (if new sample) following the Thumbnail Style Guide and templatesNew major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...Tests for the changes have been added (for bug fixes / features) (if applicable)Header has been added to all new source files (run build/UpdateHeaders.bat)Other information